diff --git a/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java b/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java index 6dbca59ce7..3ee11b3b9f 100644 --- a/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java +++ b/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.Collections; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -50,9 +51,10 @@ public class EmptyLifecycleExecutor { public MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks ) - throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException + throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, + CycleDetectedInPluginGraphException, MojoNotFoundException { - return new MavenExecutionPlan( Collections.emptyList(), null ); + return new MavenExecutionPlan( Collections. emptyList(), null ); } public void execute( MavenSession session ) @@ -73,7 +75,36 @@ public List getLifecyclePhases() public Set getPluginsBoundByDefaultToAllLifecycles( String packaging ) { - return Collections.emptySet(); + Set plugins; + + // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests + if ( "JAR".equals( packaging ) ) + { + plugins = new LinkedHashSet(); + + plugins.add( newPlugin( "maven-compiler-plugin" ) ); + plugins.add( newPlugin( "maven-resources-plugin" ) ); + plugins.add( newPlugin( "maven-surefire-plugin" ) ); + plugins.add( newPlugin( "maven-jar-plugin" ) ); + plugins.add( newPlugin( "maven-install-plugin" ) ); + plugins.add( newPlugin( "maven-deploy-plugin" ) ); + } + else + { + plugins = Collections.emptySet(); + } + + return plugins; + } + + private Plugin newPlugin( String artifactId ) + { + Plugin plugin = new Plugin(); + + plugin.setGroupId( "org.apache.maven.plugins" ); + plugin.setArtifactId( artifactId ); + + return plugin; } public void populateDefaultConfigurationForPlugins( Collection plugins, RepositoryRequest repositoryRequest ) diff --git a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java index 042b99236f..092513797f 100644 --- a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java @@ -1650,6 +1650,17 @@ public void testParentPomPackagingMustBePom() } } + /** MNG-522, MNG-3018 */ + public void testManagedPluginConfigurationAppliesToImplicitPluginsIntroducedByPackaging() + throws Exception + { + PomTestWrapper pom = buildPom( "plugin-management-for-implicit-plugin/child" ); + assertEquals( "passed.txt", + pom.getValue( "build/plugins[@artifactId='maven-resources-plugin']/configuration/pathname" ) ); + assertEquals( "passed.txt", + pom.getValue( "build/plugins[@artifactId='maven-it-plugin-log-file']/configuration/logFile" ) ); + } + private void assertPathSuffixEquals( String expected, Object actual ) { String a = actual.toString(); diff --git a/maven-core/src/test/resources-project-builder/plugin-management-for-implicit-plugin/child/pom.xml b/maven-core/src/test/resources-project-builder/plugin-management-for-implicit-plugin/child/pom.xml new file mode 100644 index 0000000000..fce3588233 --- /dev/null +++ b/maven-core/src/test/resources-project-builder/plugin-management-for-implicit-plugin/child/pom.xml @@ -0,0 +1,53 @@ + + + + + + 4.0.0 + + + org.apache.maven.its.mng0522 + parent + 1.0-SNAPSHOT + + + child-project + 1.0-SNAPSHOT + + JAR + + + + + org.apache.maven.its.plugins + maven-it-plugin-log-file + + + test + initialize + + reset + + + + + + + diff --git a/maven-core/src/test/resources-project-builder/plugin-management-for-implicit-plugin/pom.xml b/maven-core/src/test/resources-project-builder/plugin-management-for-implicit-plugin/pom.xml new file mode 100644 index 0000000000..d9412769ab --- /dev/null +++ b/maven-core/src/test/resources-project-builder/plugin-management-for-implicit-plugin/pom.xml @@ -0,0 +1,61 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng0522 + parent + 1.0-SNAPSHOT + pom + + Maven Integration Test :: MNG-522 + Test for pluginManagement injection of plugin configuration. + + + child + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 0.1-stub-SNAPSHOT + + passed.txt + + + + + org.apache.maven.its.plugins + maven-it-plugin-log-file + 2.1-SNAPSHOT + + passed.txt + + + + + +