You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/02/21 07:15:37 UTC
svn commit: r379365 - in /maven/components/trunk/maven-project/src:
main/java/org/apache/maven/project/ModelUtils.java
test/java/org/apache/maven/project/ModelUtilsTest.java
Author: brett
Date: Mon Feb 20 22:15:33 2006
New Revision: 379365
URL: http://svn.apache.org/viewcvs?rev=379365&view=rev
Log:
[MNG-1703] <pluginManagement><dependencies> is not propagated to child POMs
Submitted by: Edwin Punzalan
Modified:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/ModelUtilsTest.java
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java?rev=379365&r1=379364&r2=379365&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java Mon Feb 20 22:15:33 2006
@@ -53,6 +53,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
+import java.util.HashMap;
public final class ModelUtils
{
@@ -64,7 +65,7 @@
// nothing to do.
return;
}
-
+
List mergedPlugins = new ArrayList();
List parentPlugins = parentContainer.getPlugins();
@@ -208,6 +209,8 @@
child.setConfiguration( childConfiguration );
+ child.setDependencies( mergeDependencyList( child.getDependencies(), parent.getDependencies() ) );
+
// from here to the end of the method is dealing with merging of the <executions/> section.
String parentInherited = parent.getInherited();
@@ -1000,4 +1003,30 @@
}
}
}
+
+ public static List mergeDependencyList( List child, List parent )
+ {
+ Map depsMap = new HashMap();
+
+ if ( parent != null )
+ {
+ for ( Iterator it = parent.iterator(); it.hasNext(); )
+ {
+ Dependency dependency = (Dependency) it.next();
+ depsMap.put( dependency.getManagementKey(), dependency );
+ }
+ }
+
+ if ( child != null )
+ {
+ for ( Iterator it = child.iterator(); it.hasNext(); )
+ {
+ Dependency dependency = (Dependency) it.next();
+ depsMap.put( dependency.getManagementKey(), dependency );
+ }
+ }
+
+ return new ArrayList( depsMap.values() );
+ }
+
}
Modified: maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/ModelUtilsTest.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/ModelUtilsTest.java?rev=379365&r1=379364&r2=379365&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/ModelUtilsTest.java (original)
+++ maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/ModelUtilsTest.java Mon Feb 20 22:15:33 2006
@@ -5,6 +5,9 @@
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginContainer;
import org.apache.maven.model.PluginExecution;
+import org.apache.maven.model.Dependency;
+
+import java.util.Collections;
/*
* Copyright 2001-2005 The Apache Software Foundation.
@@ -98,7 +101,7 @@
}
/**
- * Verifies MNG-1499: The order of the merged list should be the plugins specified by the parent followed by the
+ * Verifies MNG-1499: The order of the merged list should be the plugins specified by the parent followed by the
* child list.
*/
public void testShouldKeepOriginalPluginOrdering()
@@ -112,22 +115,22 @@
parentExecution1.setId( "testExecution" );
parentPlugin1.addExecution( parentExecution1 );
-
+
Plugin parentPlugin2 = new Plugin();
parentPlugin2.setArtifactId( "testArtifact" );
parentPlugin2.setGroupId( "yyy" );
parentPlugin2.setVersion( "1.0" );
-
+
PluginExecution parentExecution2 = new PluginExecution();
parentExecution2.setId( "testExecution" );
-
+
parentPlugin2.addExecution( parentExecution2 );
-
+
PluginContainer parentContainer = new PluginContainer();
parentContainer.addPlugin(parentPlugin1);
parentContainer.addPlugin(parentPlugin2);
-
+
Plugin childPlugin1 = new Plugin();
childPlugin1.setArtifactId( "testArtifact" );
childPlugin1.setGroupId( "bbb" );
@@ -137,24 +140,24 @@
childExecution1.setId( "testExecution" );
childPlugin1.addExecution( childExecution1 );
-
+
Plugin childPlugin2 = new Plugin();
childPlugin2.setArtifactId( "testArtifact" );
childPlugin2.setGroupId( "aaa" );
childPlugin2.setVersion( "1.0" );
-
+
PluginExecution childExecution2 = new PluginExecution();
childExecution2.setId( "testExecution" );
-
+
childPlugin2.addExecution( childExecution2 );
-
+
PluginContainer childContainer = new PluginContainer();
childContainer.addPlugin(childPlugin1);
childContainer.addPlugin(childPlugin2);
-
+
ModelUtils.mergePluginLists(childContainer, parentContainer, true);
-
+
assertEquals( 4, childContainer.getPlugins().size() );
assertSame(parentPlugin1, childContainer.getPlugins().get(0));
assertSame(parentPlugin2, childContainer.getPlugins().get(1));
@@ -180,6 +183,13 @@
parent.addExecution( parentExecution1 );
parent.addExecution( parentExecution2 );
+ // this block verifies MNG-1703
+ Dependency dep = new Dependency();
+ dep.setGroupId( "depGroupId" );
+ dep.setArtifactId( "depArtifactId" );
+ dep.setVersion( "depVersion" );
+ parent.setDependencies( Collections.singletonList( dep ) );
+
Plugin child = new Plugin();
child.setArtifactId( "testArtifact" );
child.setGroupId( "testGroup" );
@@ -200,5 +210,10 @@
assertSame(parentExecution2, child.getExecutions().get(1));
assertSame(childExecution1, child.getExecutions().get(2));
assertSame(childExecution2, child.getExecutions().get(3));
+
+ // this block prevents MNG-1703
+ assertEquals( 1, child.getDependencies().size() );
+ Dependency dep2 = (Dependency) child.getDependencies().get( 0 );
+ assertEquals( dep.getManagementKey(), dep2.getManagementKey() );
}
}