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:
Britton Isbell 2009-02-03 22:43:53 +00:00
parent cb077dc469
commit 4267580f46
4 changed files with 50 additions and 4 deletions

View File

@ -560,7 +560,6 @@ public class PomTransformer
tmp.removeAll(replace);
//Missing Version Rule
if ( getPropertyFor( ProjectUri.version, tmp ) == null )
{
@ -742,6 +741,27 @@ public class PomTransformer
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
ModelDataSource source = new DefaultModelDataSource( modelProperties, PomTransformer.MODEL_CONTAINER_FACTORIES );

View File

@ -350,7 +350,7 @@ public class ProjectUri
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";
}

View File

@ -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
public void testDependenciesDifferentVersions()
throws Exception
@ -748,11 +757,12 @@ public class PomConstructionTest
assertPathWithNormalizedFileSeparators( pom.getValue( "reporting/outputDirectory" ) );
}
/* FIXME: cf. MNG-4008
/* MNG-4008 */
public void testMergedFilterOrder()
throws Exception
{
PomTestWrapper pom = buildPom( "merged-filter-order/sub" );
System.out.println(pom.getValue( "build/filters" ));
assertEquals( 7, ( (List<?>) pom.getValue( "build/filters" ) ).size() );
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[7]" ).toString().endsWith( "parent-d.properties" ) );
}
//*/
private void assertPathWithNormalizedFileSeparators( Object value )
{

View File

@ -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>