mirror of https://github.com/apache/maven.git
[MNG-4007] [regression] Effective model contains paths with non-normalized file separators
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@738074 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eb08946492
commit
ea2773c5eb
|
@ -19,6 +19,7 @@ package org.apache.maven.project.builder;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
|
@ -137,6 +138,23 @@ public class PomTransformer
|
|||
|
||||
ProjectUri.Repositories.xUri) ));
|
||||
|
||||
/**
|
||||
* The URIs that denote file/directory paths and need their file separators being normalized.
|
||||
*/
|
||||
private static final Set<String> PATH_URIS =
|
||||
Collections.unmodifiableSet( new HashSet<String>(
|
||||
Arrays.asList(
|
||||
ProjectUri.Build.directory,
|
||||
ProjectUri.Build.outputDirectory,
|
||||
ProjectUri.Build.testOutputDirectory,
|
||||
ProjectUri.Build.sourceDirectory,
|
||||
ProjectUri.Build.testSourceDirectory,
|
||||
ProjectUri.Build.scriptSourceDirectory,
|
||||
ProjectUri.Build.Resources.Resource.directory,
|
||||
ProjectUri.Build.TestResources.TestResource.directory,
|
||||
ProjectUri.Build.filters + "/filter",
|
||||
ProjectUri.Reporting.outputDirectory ) ) );
|
||||
|
||||
/**
|
||||
* @see ModelTransformer#transformToDomainModel(java.util.List, java.util.List)
|
||||
*/
|
||||
|
@ -408,11 +426,17 @@ public class PomTransformer
|
|||
p.add(mp);
|
||||
}
|
||||
}
|
||||
else if ( mp.getResolvedValue() != null && PATH_URIS.contains( mp.getUri() ) )
|
||||
{
|
||||
// normalize file separator
|
||||
p.add( new ModelProperty( mp.getUri(), new File( mp.getResolvedValue() ).getPath() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
p.add(mp);
|
||||
}
|
||||
}
|
||||
|
||||
return factory.createDomainModel( p );
|
||||
}
|
||||
|
||||
|
|
|
@ -650,6 +650,26 @@ public class PomConstructionTest
|
|||
assertEquals( "d", pom.getValue( "dependencies[4]/artifactId" ) );
|
||||
}
|
||||
|
||||
public void testBuildDirectoriesUsePlatformSpecificFileSeparator()
|
||||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "platform-file-separator" );
|
||||
assertPathWithNormalizedFileSeparators( pom.getValue( "build/directory" ) );
|
||||
assertPathWithNormalizedFileSeparators( pom.getValue( "build/outputDirectory" ) );
|
||||
assertPathWithNormalizedFileSeparators( pom.getValue( "build/testOutputDirectory" ) );
|
||||
assertPathWithNormalizedFileSeparators( pom.getValue( "build/sourceDirectory" ) );
|
||||
assertPathWithNormalizedFileSeparators( pom.getValue( "build/testSourceDirectory" ) );
|
||||
assertPathWithNormalizedFileSeparators( pom.getValue( "build/resources[1]/directory" ) );
|
||||
assertPathWithNormalizedFileSeparators( pom.getValue( "build/testResources[1]/directory" ) );
|
||||
assertPathWithNormalizedFileSeparators( pom.getValue( "build/filters[1]" ) );
|
||||
assertPathWithNormalizedFileSeparators( pom.getValue( "reporting/outputDirectory" ) );
|
||||
}
|
||||
|
||||
private void assertPathWithNormalizedFileSeparators( Object value )
|
||||
{
|
||||
assertEquals( new File( value.toString() ).getPath(), value.toString() );
|
||||
}
|
||||
|
||||
private PomArtifactResolver artifactResolver( String basedir )
|
||||
{
|
||||
return new FileBasedPomArtifactResolver( new File( BASE_POM_DIR, basedir ) );
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.apache.maven.its.mng3877</groupId>
|
||||
<artifactId>test</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Maven Integration Test :: MNG-3877</name>
|
||||
<description>
|
||||
Verify that paths to project directories use the platform-specific file separator.
|
||||
</description>
|
||||
|
||||
<build>
|
||||
<filters>
|
||||
<filter>src/main/filters/it.properties</filter>
|
||||
</filters>
|
||||
</build>
|
||||
</project>
|
Loading…
Reference in New Issue