Corrected goal and plugin configuration injection (from managed info).

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@165096 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-04-28 04:21:11 +00:00
parent a5c141c146
commit dfb2dfcaa1
1 changed files with 40 additions and 8 deletions

View File

@ -18,6 +18,7 @@ package org.apache.maven.project.injection;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.Goal;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginManagement;
@ -90,17 +91,48 @@ public class DefaultModelDefaultsInjector
plugin.setVersion( def.getVersion() );
}
List pluginGoals = plugin.getGoals();
if( pluginGoals == null || pluginGoals.isEmpty() )
Map defaultGoals = new TreeMap();
List defGoalList = def.getGoals();
if ( defGoalList != null )
{
plugin.setGoals( def.getGoals() );
for ( Iterator it = defGoalList.iterator(); it.hasNext(); )
{
Goal defaultGoal = (Goal) it.next();
defaultGoals.put( defaultGoal.getId(), defaultGoal );
}
}
List pluginGoals = plugin.getGoals();
if ( pluginGoals != null )
{
for ( Iterator it = pluginGoals.iterator(); it.hasNext(); )
{
Goal pluginGoal = (Goal) it.next();
Goal defaultGoal = (Goal) defaultGoals.get( pluginGoal.getId() );
if ( defaultGoal != null )
{
Xpp3Dom pluginGoalConfig = (Xpp3Dom) pluginGoal.getConfiguration();
Xpp3Dom defaultGoalConfig = (Xpp3Dom) defaultGoal.getConfiguration();
pluginGoalConfig = Xpp3Dom.mergeXpp3Dom( pluginGoalConfig, defaultGoalConfig );
pluginGoal.setConfiguration( pluginGoalConfig );
}
}
}
Xpp3Dom pluginConfiguration = (Xpp3Dom) plugin.getConfiguration();
if( pluginConfiguration == null )
{
plugin.setConfiguration( def.getConfiguration() );
}
Xpp3Dom defaultConfiguration = (Xpp3Dom) def.getConfiguration();
pluginConfiguration = Xpp3Dom.mergeXpp3Dom( pluginConfiguration, defaultConfiguration );
plugin.setConfiguration( pluginConfiguration );
}
private void injectDependencyDefaults( List dependencies, DependencyManagement dependencyManagement )