From dfb2dfcaa14d80c977f54c1a39ba868e6036d79e Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Thu, 28 Apr 2005 04:21:11 +0000 Subject: [PATCH] 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 --- .../DefaultModelDefaultsInjector.java | 48 +++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/maven-project/src/main/java/org/apache/maven/project/injection/DefaultModelDefaultsInjector.java b/maven-project/src/main/java/org/apache/maven/project/injection/DefaultModelDefaultsInjector.java index 8ad27e57a7..b94d93e529 100644 --- a/maven-project/src/main/java/org/apache/maven/project/injection/DefaultModelDefaultsInjector.java +++ b/maven-project/src/main/java/org/apache/maven/project/injection/DefaultModelDefaultsInjector.java @@ -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; @@ -89,18 +90,49 @@ public class DefaultModelDefaultsInjector { plugin.setVersion( def.getVersion() ); } - + + Map defaultGoals = new TreeMap(); + + List defGoalList = def.getGoals(); + + if ( defGoalList != null ) + { + for ( Iterator it = defGoalList.iterator(); it.hasNext(); ) + { + Goal defaultGoal = (Goal) it.next(); + + defaultGoals.put( defaultGoal.getId(), defaultGoal ); + } + } + List pluginGoals = plugin.getGoals(); - if( pluginGoals == null || pluginGoals.isEmpty() ) + + if ( pluginGoals != null ) { - plugin.setGoals( def.getGoals() ); + 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 )