[MNG-3018] pluginManagement configurations are not honoured when plugin is silently included

o Added UT

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@804257 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-08-14 15:19:51 +00:00
parent 977d3bccdc
commit acdfa7e8df
4 changed files with 159 additions and 3 deletions

View File

@ -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.<MojoExecution>emptyList(), null );
return new MavenExecutionPlan( Collections.<MojoExecution> emptyList(), null );
}
public void execute( MavenSession session )
@ -73,7 +75,36 @@ public List<String> getLifecyclePhases()
public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging )
{
return Collections.emptySet();
Set<Plugin> 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<Plugin>();
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<Plugin> plugins, RepositoryRequest repositoryRequest )

View File

@ -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();

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.maven.its.mng0522</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>child-project</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- NOTE: The upper-case packaging name is intentional and triggers a special mode in the EmptyLifecycleExecutor -->
<packaging>JAR</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-log-file</artifactId>
<executions>
<execution>
<id>test</id>
<phase>initialize</phase>
<goals>
<goal>reset</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng0522</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Maven Integration Test :: MNG-522</name>
<description>Test for pluginManagement injection of plugin configuration.</description>
<modules>
<module>child</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<!-- this checks handling of a plugin which is implicitly bound to the lifecycle -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>0.1-stub-SNAPSHOT</version>
<configuration>
<pathname>passed.txt</pathname>
</configuration>
</plugin>
<plugin>
<!-- this checks handling of a plugin which is explicitly bound to the lifecycle -->
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-log-file</artifactId>
<version>2.1-SNAPSHOT</version>
<configuration>
<logFile>passed.txt</logFile>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>