From e4083dcdea2f468569f76943de2c2e1276784a70 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Sat, 25 Jun 2005 00:00:05 +0000 Subject: [PATCH] Resolving issue: MNG-522 o Added check for null child pluginManagement section, and setting to parent value if null. o Added integration test for parent->child pluginManagement inheritance and injection, to prevent regressions. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@201693 13f79535-47bb-0310-9956-ffa450edef68 --- maven-core-it/README.txt | 2 + maven-core-it/integration-tests.txt | 1 + maven-core-it/it0029/child-project/pom.xml | 29 ++++++++++++++ .../java/org/apache/maven/it0001/Person.java | 18 +++++++++ maven-core-it/it0029/expected-results.txt | 1 + maven-core-it/it0029/goals.txt | 1 + maven-core-it/it0029/pom.xml | 38 +++++++++++++++++++ maven-core-it/it0029/prebuild-hook.txt | 2 + .../DefaultModelInheritanceAssembler.java | 13 ++++++- 9 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 maven-core-it/it0029/child-project/pom.xml create mode 100644 maven-core-it/it0029/child-project/src/main/java/org/apache/maven/it0001/Person.java create mode 100644 maven-core-it/it0029/expected-results.txt create mode 100644 maven-core-it/it0029/goals.txt create mode 100644 maven-core-it/it0029/pom.xml create mode 100644 maven-core-it/it0029/prebuild-hook.txt diff --git a/maven-core-it/README.txt b/maven-core-it/README.txt index 03e9d77908..16ba27f2d4 100644 --- a/maven-core-it/README.txt +++ b/maven-core-it/README.txt @@ -88,6 +88,8 @@ it0027: Test @execute with a custom lifecycle, including configuration it0028: Test that unused configuration parameters from the POM don't cause the mojo to fail...they will show up as warnings in the -X output instead. +it0029: Test for pluginManagement injection of plugin configuration. + ------------------------------------------------------------------------------- - generated sources diff --git a/maven-core-it/integration-tests.txt b/maven-core-it/integration-tests.txt index afdc7e9d83..ec8c139552 100644 --- a/maven-core-it/integration-tests.txt +++ b/maven-core-it/integration-tests.txt @@ -1,3 +1,4 @@ +it0029 it0028 it0027 it0026 diff --git a/maven-core-it/it0029/child-project/pom.xml b/maven-core-it/it0029/child-project/pom.xml new file mode 100644 index 0000000000..cf2e65b384 --- /dev/null +++ b/maven-core-it/it0029/child-project/pom.xml @@ -0,0 +1,29 @@ + + 4.0.0 + + org.apache.maven.it + maven-core-it0030 + 1.0-SNAPSHOT + + org.apache.maven.it + maven-core-it0030-child + jar + 1.0-SNAPSHOT + + + junit + junit + 3.8.1 + jar + test + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + diff --git a/maven-core-it/it0029/child-project/src/main/java/org/apache/maven/it0001/Person.java b/maven-core-it/it0029/child-project/src/main/java/org/apache/maven/it0001/Person.java new file mode 100644 index 0000000000..8688a620db --- /dev/null +++ b/maven-core-it/it0029/child-project/src/main/java/org/apache/maven/it0001/Person.java @@ -0,0 +1,18 @@ +package org.apache.maven.it0001; + +public class Person +{ + private String name; + + public void setName( String newName ) + { + assert true; + + this.name = newName; + } + + public String getName() + { + return name; + } +} diff --git a/maven-core-it/it0029/expected-results.txt b/maven-core-it/it0029/expected-results.txt new file mode 100644 index 0000000000..a311cf5303 --- /dev/null +++ b/maven-core-it/it0029/expected-results.txt @@ -0,0 +1 @@ +child-project/target/classes/org/apache/maven/it0001/Person.class diff --git a/maven-core-it/it0029/goals.txt b/maven-core-it/it0029/goals.txt new file mode 100644 index 0000000000..7c32f55981 --- /dev/null +++ b/maven-core-it/it0029/goals.txt @@ -0,0 +1 @@ +install diff --git a/maven-core-it/it0029/pom.xml b/maven-core-it/it0029/pom.xml new file mode 100644 index 0000000000..73e5383d9c --- /dev/null +++ b/maven-core-it/it0029/pom.xml @@ -0,0 +1,38 @@ + + 4.0.0 + org.apache.maven.it + maven-core-it0030 + 1.0-SNAPSHOT + pom + + + child-project + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + 1.4 + 1.4 + + + + + + diff --git a/maven-core-it/it0029/prebuild-hook.txt b/maven-core-it/it0029/prebuild-hook.txt new file mode 100644 index 0000000000..c8a8c9b229 --- /dev/null +++ b/maven-core-it/it0029/prebuild-hook.txt @@ -0,0 +1,2 @@ +rm ${artifact:org.apache.maven.it:maven-core-it0029:1.0-SNAPSHOT:jar} +rm ${artifact:org.apache.maven.it:maven-core-it0029-child:1.0-SNAPSHOT:jar} diff --git a/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java b/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java index dace0eb234..a0604fa70e 100644 --- a/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java +++ b/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java @@ -23,6 +23,7 @@ import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.Model; import org.apache.maven.model.ModelBase; +import org.apache.maven.model.PluginManagement; import org.apache.maven.model.Profile; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.ReportSet; @@ -483,7 +484,17 @@ public class DefaultModelInheritanceAssembler // Plugin management :: aggregate if ( childBuild != null && parentBuild != null ) { - ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(), false ); + PluginManagement childPM = childBuild.getPluginManagement(); + PluginManagement parentPM = parentBuild.getPluginManagement(); + + if( childPM == null && parentPM !=null ) + { + childBuild.setPluginManagement( parentPM ); + } + else + { + ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(), false ); + } } }