Fixing per MNG-357. Inheritance/injection of pluginManagement did not follow the same conventions intended and established by that of dependencyManagement. This fix makes the two more consistent, and allows for more local control over plugin configuration.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@165016 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-04-27 17:37:50 +00:00
parent ed14ff454d
commit 7d7c4ed4aa
2 changed files with 17 additions and 38 deletions

View File

@ -239,13 +239,16 @@ public class DefaultModelInheritanceAssembler
for ( Iterator it = parentPluginMgmt.getPlugins().iterator(); it.hasNext(); )
{
Plugin plugin = (Plugin) it.next();
if ( !mappedChildPlugins.containsKey( constructPluginKey( plugin ) ) )
String pluginKey = constructPluginKey( plugin );
if ( !mappedChildPlugins.containsKey( pluginKey ) )
{
childPluginMgmt.addPlugin( plugin );
}
else
{
Plugin childPlugin = (Plugin) mappedChildPlugins.get( constructPluginKey( plugin ) );
Plugin childPlugin = (Plugin) mappedChildPlugins.get( pluginKey );
if ( childPlugin.getVersion() == null )
{
@ -275,6 +278,10 @@ public class DefaultModelInheritanceAssembler
childGoal.setConfiguration( Xpp3Dom.mergeXpp3Dom( childDom, parentDom ) );
}
}
Xpp3Dom childConfig = (Xpp3Dom) childPlugin.getConfiguration();
Xpp3Dom parentConfig = (Xpp3Dom) plugin.getConfiguration();
childPlugin.setConfiguration( Xpp3Dom.mergeXpp3Dom( childConfig, parentConfig ) );
}
}
}

View File

@ -91,46 +91,18 @@ public class DefaultModelDefaultsInjector
{
plugin.setVersion( def.getVersion() );
}
Map goalMap = new TreeMap();
List pluginGoals = plugin.getGoals();
if ( pluginGoals != null )
if( pluginGoals == null || pluginGoals.isEmpty() )
{
for ( Iterator it = pluginGoals.iterator(); it.hasNext(); )
{
Goal goal = (Goal) it.next();
goalMap.put( goal.getId(), goal );
}
plugin.setGoals( def.getGoals() );
}
List defGoals = def.getGoals();
if ( defGoals != null )
{
for ( Iterator it = defGoals.iterator(); it.hasNext(); )
{
Goal defaultGoal = (Goal) it.next();
Goal localGoal = (Goal) goalMap.get( defaultGoal.getId() );
if ( localGoal == null )
{
goalMap.put( defaultGoal.getId(), defaultGoal );
}
else
{
Xpp3Dom goalConfiguration = (Xpp3Dom) localGoal.getConfiguration();
Xpp3Dom defaultGoalConfiguration = (Xpp3Dom) defaultGoal.getConfiguration();
localGoal.setConfiguration( Xpp3Dom.mergeXpp3Dom( goalConfiguration, defaultGoalConfiguration ) );
}
}
}
plugin.setGoals( new ArrayList( goalMap.values() ) );
Xpp3Dom pluginConfiguration = (Xpp3Dom) plugin.getConfiguration();
Xpp3Dom defaultPluginConfiguration = (Xpp3Dom) def.getConfiguration();
plugin.setConfiguration( Xpp3Dom.mergeXpp3Dom( pluginConfiguration, defaultPluginConfiguration ) );
if( pluginConfiguration == null )
{
plugin.setConfiguration( def.getConfiguration() );
}
}
private void injectDependencyDefaults( List dependencies, DependencyManagement dependencyManagement )