Resolving: MNG-985...simply fixed merging of plugins from PluginManagement to happen on a plugin-by-plugin basis using individual merge logic from ModelUtils, rather than the wholesale merge logic for plugin lists.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@292255 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-09-28 18:57:22 +00:00
parent b975bdad38
commit 03b6c44316
4 changed files with 69 additions and 1 deletions

View File

@ -200,6 +200,10 @@ it0074: Test that plugin-level configuration instances are not nullified by
it0075: Verify that direct invocation of a mojo from the command line still
results in the processing of modules included via profiles.
it0076: Test that plugins in pluginManagement aren't included in the build
unless they are referenced by groupId/artifactId within the plugins
section of a pom.
-------------------------------------------------------------------------------
- generated sources

View File

@ -1,3 +1,4 @@
it0076
it0075
it0074
it0073

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.it</groupId>
<artifactId>maven-core-it0076</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>exec1</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -16,10 +16,12 @@ package org.apache.maven.project.injection;
* limitations under the License.
*/
import org.apache.maven.model.Build;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginManagement;
import org.apache.maven.project.ModelUtils;
import java.util.Iterator;
@ -38,10 +40,42 @@ public class DefaultModelDefaultsInjector
injectDependencyDefaults( model.getDependencies(), model.getDependencyManagement() );
if ( model.getBuild() != null )
{
ModelUtils.mergePluginLists( model.getBuild(), model.getBuild().getPluginManagement(), false );
injectPluginDefaults( model.getBuild(), model.getBuild().getPluginManagement() );
}
}
private void injectPluginDefaults( Build build, PluginManagement pluginManagement )
{
if ( pluginManagement == null )
{
// nothing to inject.
return ;
}
List buildPlugins = build.getPlugins();
if ( buildPlugins != null && !buildPlugins.isEmpty() )
{
Map pmPlugins = pluginManagement.getPluginsAsMap();
if ( pmPlugins != null && !pmPlugins.isEmpty() )
{
for ( Iterator it = buildPlugins.iterator(); it.hasNext(); )
{
Plugin buildPlugin = (Plugin) it.next();
Plugin pmPlugin = (Plugin) pmPlugins.get( buildPlugin.getKey() );
if ( pmPlugin != null )
{
mergePluginWithDefaults( buildPlugin, pmPlugin );
}
}
}
}
}
public void mergePluginWithDefaults( Plugin plugin, Plugin def )
{
ModelUtils.mergePluginDefinitions( plugin, def, false );