mirror of https://github.com/apache/maven.git
MNG-4008: Multiple filters.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@740495 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cb077dc469
commit
4267580f46
|
@ -559,7 +559,6 @@ public class PomTransformer
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp.removeAll(replace);
|
tmp.removeAll(replace);
|
||||||
|
|
||||||
|
|
||||||
//Missing Version Rule
|
//Missing Version Rule
|
||||||
if ( getPropertyFor( ProjectUri.version, tmp ) == null )
|
if ( getPropertyFor( ProjectUri.version, tmp ) == null )
|
||||||
|
@ -742,6 +741,27 @@ public class PomTransformer
|
||||||
modelProperties.removeAll( clearedProperties );
|
modelProperties.removeAll( clearedProperties );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Rules processed on collapsed pom
|
||||||
|
|
||||||
|
//Rule: Remove duplicate filters
|
||||||
|
List<ModelProperty> removedProperties = new ArrayList<ModelProperty>();
|
||||||
|
List<String> filters = new ArrayList<String>();
|
||||||
|
for(ModelProperty mp : modelProperties)
|
||||||
|
{
|
||||||
|
if(mp.getUri().equals(ProjectUri.Build.Filters.filter))
|
||||||
|
{
|
||||||
|
if(filters.contains(mp.getResolvedValue()))
|
||||||
|
{
|
||||||
|
removedProperties.add(mp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filters.add(mp.getResolvedValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modelProperties.removeAll(removedProperties);
|
||||||
|
|
||||||
//Rule: Build plugin config overrides reporting plugin config
|
//Rule: Build plugin config overrides reporting plugin config
|
||||||
ModelDataSource source = new DefaultModelDataSource( modelProperties, PomTransformer.MODEL_CONTAINER_FACTORIES );
|
ModelDataSource source = new DefaultModelDataSource( modelProperties, PomTransformer.MODEL_CONTAINER_FACTORIES );
|
||||||
|
|
||||||
|
|
|
@ -350,7 +350,7 @@ public class ProjectUri
|
||||||
|
|
||||||
public static class Filters
|
public static class Filters
|
||||||
{
|
{
|
||||||
public static String xUri = "http://apache.org/maven/project/build/filters#set";
|
public static String xUri = "http://apache.org/maven/project/build/filters#collection";
|
||||||
|
|
||||||
public static String filter = xUri + "/filter";
|
public static String filter = xUri + "/filter";
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,6 +136,15 @@ public class PomConstructionTest
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*MNG- 4008*/
|
||||||
|
public void testMultipleFilters()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
PomTestWrapper pom = buildPom( "multiple-filters" );
|
||||||
|
assertEquals( 4, ( (List<?>) pom.getValue( "build/filters" ) ).size() );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*MNG-4005 - not implemented
|
/*MNG-4005 - not implemented
|
||||||
public void testDependenciesDifferentVersions()
|
public void testDependenciesDifferentVersions()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
@ -748,11 +757,12 @@ public class PomConstructionTest
|
||||||
assertPathWithNormalizedFileSeparators( pom.getValue( "reporting/outputDirectory" ) );
|
assertPathWithNormalizedFileSeparators( pom.getValue( "reporting/outputDirectory" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: cf. MNG-4008
|
/* MNG-4008 */
|
||||||
public void testMergedFilterOrder()
|
public void testMergedFilterOrder()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
PomTestWrapper pom = buildPom( "merged-filter-order/sub" );
|
PomTestWrapper pom = buildPom( "merged-filter-order/sub" );
|
||||||
|
|
||||||
System.out.println(pom.getValue( "build/filters" ));
|
System.out.println(pom.getValue( "build/filters" ));
|
||||||
assertEquals( 7, ( (List<?>) pom.getValue( "build/filters" ) ).size() );
|
assertEquals( 7, ( (List<?>) pom.getValue( "build/filters" ) ).size() );
|
||||||
assertTrue( pom.getValue( "build/filters[1]" ).toString().endsWith( "child-a.properties" ) );
|
assertTrue( pom.getValue( "build/filters[1]" ).toString().endsWith( "child-a.properties" ) );
|
||||||
|
@ -763,7 +773,7 @@ public class PomConstructionTest
|
||||||
assertTrue( pom.getValue( "build/filters[6]" ).toString().endsWith( "parent-b.properties" ) );
|
assertTrue( pom.getValue( "build/filters[6]" ).toString().endsWith( "parent-b.properties" ) );
|
||||||
assertTrue( pom.getValue( "build/filters[7]" ).toString().endsWith( "parent-d.properties" ) );
|
assertTrue( pom.getValue( "build/filters[7]" ).toString().endsWith( "parent-d.properties" ) );
|
||||||
}
|
}
|
||||||
//*/
|
|
||||||
|
|
||||||
private void assertPathWithNormalizedFileSeparators( Object value )
|
private void assertPathWithNormalizedFileSeparators( Object value )
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<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>a</groupId>
|
||||||
|
<artifactId>b</artifactId>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<filters>
|
||||||
|
<filter>src/main/filters/a.properties</filter>
|
||||||
|
<filter>src/main/filters/c.properties</filter>
|
||||||
|
<filter>src/main/filters/b.properties</filter>
|
||||||
|
<filter>src/main/filters/d.properties</filter>
|
||||||
|
</filters>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
Loading…
Reference in New Issue