You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/06/18 15:01:27 UTC

svn commit: r191285 - /maven/components/trunk/maven-core-it/it0008 /maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle /maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin /maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version /maven/components/trunk/maven-core/src/test/java/org/apache/maven/lifecycle /maven/components/trunk/maven-model /maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor /maven/components/trunk/maven-project/src/main/java/org/apache/maven/project /maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance

Author: brett
Date: Sat Jun 18 06:01:26 2005
New Revision: 191285

URL: http://svn.apache.org/viewcvs?rev=191285&view=rev
Log:
Clean up of the lifecycle executor, simplify configuration and push back into the plugin manager.
This fixed a couple of bugs along the way.

One change that this has brought to bear from the document is you now must specify a goal for it to be bound to the LC
(see it0008)

Added:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java
Removed:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/GoalInstance.java
    maven/components/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
Modified:
    maven/components/trunk/maven-core-it/it0008/pom.xml
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
    maven/components/trunk/maven-model/maven.mdo
    maven/components/trunk/maven-model/pom.xml
    maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java

Modified: maven/components/trunk/maven-core-it/it0008/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0008/pom.xml?rev=191285&r1=191284&r2=191285&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/it0008/pom.xml (original)
+++ maven/components/trunk/maven-core-it/it0008/pom.xml Sat Jun 18 06:01:26 2005
@@ -19,6 +19,11 @@
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-core-it-plugin</artifactId>
         <version>1.0-SNAPSHOT</version>
+        <goals>
+          <goal>
+            <id>touch</id>
+          </goal>
+        </goals>
       </plugin>
     </plugins>
   </build>

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=191285&r1=191284&r2=191285&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Sat Jun 18 06:01:26 2005
@@ -16,6 +16,7 @@
  * limitations under the License.
  */
 
+import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.execution.MavenExecutionResponse;
 import org.apache.maven.execution.MavenSession;
@@ -24,7 +25,7 @@
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.PluginExecution;
 import org.apache.maven.model.PluginManagement;
-import org.apache.maven.plugin.GoalInstance;
+import org.apache.maven.plugin.MojoExecution;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.PluginManager;
 import org.apache.maven.plugin.PluginManagerException;
@@ -48,11 +49,10 @@
 import java.util.StringTokenizer;
 
 /**
- * @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  * @version $Id: DefaultLifecycleExecutor.java,v 1.16 2005/03/04 09:04:25
  *          jdcasey Exp $
- * @todo this is structured somewhat confusingly. Attempt to "flatten out" to reduce the number of paths through by
- * compiling the list of plugins/tasks first.
  */
 public class DefaultLifecycleExecutor
     extends AbstractLogEnabled
@@ -75,7 +75,7 @@
     // ----------------------------------------------------------------------
 
     /**
-     * Execute a list of tasks. Each task may be a phase in the lifecycle or the
+     * Execute a task. Each task may be a phase in the lifecycle or the
      * execution of a mojo.
      *
      * @param tasks
@@ -90,7 +90,11 @@
 
         try
         {
-            processGoals( session, tasks );
+            for ( Iterator i = tasks.iterator(); i.hasNext(); )
+            {
+                String task = (String) i.next();
+                executeGoal( task, session );
+            }
         }
         catch ( MojoExecutionException e )
         {
@@ -108,14 +112,12 @@
         return response;
     }
 
-    private void processGoals( MavenSession session, List tasks )
-        throws LifecycleExecutionException, PluginNotFoundException, MojoExecutionException,
-        ArtifactResolutionException
+    private void executeGoal( String task, MavenSession session )
+        throws LifecycleExecutionException, PluginNotFoundException, MojoExecutionException, ArtifactResolutionException
     {
         Map phaseMap = new HashMap();
-        Map goalInstanceMap = new HashMap();
 
-        String maxPhase = null;
+        String selectedPhase = null;
 
         for ( Iterator i = phases.iterator(); i.hasNext(); )
         {
@@ -124,192 +126,111 @@
             // Make a copy of the phase as we will modify it
             phaseMap.put( p, new ArrayList() );
 
-            if ( tasks.contains( p ) )
+            if ( task.equals( p ) )
             {
-                maxPhase = p;
+                selectedPhase = p;
             }
         }
 
-        MavenProject project = session.getProject();
+        List goals;
 
-        if ( maxPhase != null )
+        // Need to verify all the plugins up front, as standalone goals should use the version from the POM.
+        for ( Iterator i = session.getProject().getBuildPlugins().iterator(); i.hasNext(); )
         {
-            Map mappings;
-            try
-            {
-                LifecycleMapping m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, project.getPackaging() );
-                mappings = m.getPhases();
-            }
-            catch ( ComponentLookupException e )
-            {
-                getLogger().error( "No lifecycle mapping for type '" + project.getPackaging() + "': using defaults" );
-                mappings = defaultPhases;
-            }
-
-            for ( Iterator i = phases.iterator(); i.hasNext(); )
-            {
-                String phase = (String) i.next();
-
-                String phaseTasks = (String) mappings.get( phase );
-
-                if ( phaseTasks != null )
-                {
-                    for ( StringTokenizer tok = new StringTokenizer( phaseTasks, "," ); tok.hasMoreTokens(); )
-                    {
-                        String task = tok.nextToken().trim();
-
-                        MojoDescriptor mojoDescriptor = configureMojo( task, session, phaseMap );
-
-                        addToPhaseMap( phaseMap, phase, mojoDescriptor );
-
-                        List matchingGoalInstances = findMatchingGoalInstances( mojoDescriptor, project );
-
-                        for ( Iterator instanceIterator = matchingGoalInstances.iterator(); instanceIterator.hasNext(); )
-                        {
-                            GoalInstance goalInstance = (GoalInstance) instanceIterator.next();
-
-                            addToGoalInstanceMap( goalInstanceMap, goalInstance );
-                        }
-                    }
-                }
+            Plugin plugin = (Plugin) i.next();
 
-                if ( phase.equals( maxPhase ) )
-                {
-                    break;
-                }
-            }
+            verifyPlugin( plugin, session );
         }
 
-        processPluginConfiguration( project, session, phaseMap, goalInstanceMap );
-
-        for ( Iterator i = tasks.iterator(); i.hasNext(); )
+        if ( selectedPhase != null )
         {
-            String task = (String) i.next();
+            // we have a lifecycle phase, so lets bind all the necessary goals
+            constructLifecyclePhaseMap( session, phaseMap, selectedPhase );
 
-            // verify that all loose-leaf goals have had GoalInstance(s) configured for them...
-            // we only need to do this if the current task is not a phase name.
-            if ( !phaseMap.containsKey( task ) )
-            {
-                MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session );
+            goals = processGoalChain( selectedPhase, phaseMap );
+        }
+        else
+        {
+            MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session );
+            goals = Collections.singletonList( new MojoExecution( mojoDescriptor ) );
+        }
 
-                if ( mojoDescriptor != null && !goalInstanceMap.containsKey( mojoDescriptor ) )
-                {
-                    List matchingGoalInstances = findMatchingGoalInstances( mojoDescriptor, project );
+        for ( Iterator i = goals.iterator(); i.hasNext(); )
+        {
+            MojoExecution mojoExecution = (MojoExecution) i.next();
 
-                    for ( Iterator instanceIterator = matchingGoalInstances.iterator(); instanceIterator.hasNext(); )
-                    {
-                        GoalInstance goalInstance = (GoalInstance) instanceIterator.next();
+            String executePhase = mojoExecution.getMojoDescriptor().getExecutePhase();
 
-                        addToGoalInstanceMap( goalInstanceMap, goalInstance );
-                    }
-                }
+            if ( executePhase != null )
+            {
+                // TODO: with introduction of cloned lifecyle, we want to avoid reconstructing some things - narrow
+                executeGoal( executePhase, session );
             }
 
-            // now we can proceed to actually load up the list of goals we're interested in.
-            List goals = processGoalChain( task, session, phaseMap );
-
-            for ( Iterator j = goals.iterator(); j.hasNext(); )
+            try
             {
-                MojoDescriptor mojoDescriptor = (MojoDescriptor) j.next();
-
-                List instances = (List) goalInstanceMap.get( mojoDescriptor );
-
-                if ( instances != null )
-                {
-                    for ( Iterator instanceIterator = instances.iterator(); instanceIterator.hasNext(); )
-                    {
-                        GoalInstance instance = (GoalInstance) instanceIterator.next();
-
-                        String executePhase = mojoDescriptor.getExecutePhase();
-
-                        if ( executePhase != null )
-                        {
-                            // TODO: is this too broad to execute?
-                            execute( Collections.singletonList( executePhase ), session );
-                        }
-
-                        try
-                        {
-                            pluginManager.executeMojo( session, instance );
-                        }
-                        catch ( PluginManagerException e )
-                        {
-                            throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
-                        }
-                    }
-                }
-                else
-                {
-                    throw new LifecycleExecutionException( "This goal has not been configured: "
-                        + mojoDescriptor.getGoal() );
-                }
+                pluginManager.executeMojo( mojoExecution, session );
+            }
+            catch ( PluginManagerException e )
+            {
+                throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
             }
         }
     }
 
-    private void addToGoalInstanceMap( Map goalInstanceMap, GoalInstance goalInstance )
+    private void constructLifecyclePhaseMap( MavenSession session, Map phaseMap, String selectedPhase )
+        throws ArtifactResolutionException, LifecycleExecutionException
     {
-        MojoDescriptor mojoDescriptor = goalInstance.getMojoDescriptor();
+        // first, bind those associated with the packaging
+        bindLifecycleForPackaging( session, phaseMap, selectedPhase );
 
-        List instances = (List) goalInstanceMap.get( mojoDescriptor );
-
-        if ( instances == null )
+        // next, loop over plugins and for any that have a phase, bind it
+        for ( Iterator i = session.getProject().getBuildPlugins().iterator(); i.hasNext(); )
         {
-            instances = new ArrayList();
+            Plugin plugin = (Plugin) i.next();
 
-            goalInstanceMap.put( mojoDescriptor, instances );
+            bindPluginToLifecycle( plugin, session, phaseMap );
         }
+    }
 
-        int idx = instances.indexOf( goalInstance );
-
-        if ( idx > -1 )
+    private void bindLifecycleForPackaging( MavenSession session, Map phaseMap, String selectedPhase )
+        throws ArtifactResolutionException, LifecycleExecutionException
+    {
+        Map mappings;
+        String packaging = session.getProject().getPackaging();
+        try
         {
-            GoalInstance cached = (GoalInstance) instances.get( idx );
-
-            cached.incorporate( goalInstance );
+            LifecycleMapping m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, packaging );
+            mappings = m.getPhases();
         }
-        else
+        catch ( ComponentLookupException e )
         {
-            instances.add( goalInstance );
+            getLogger().error( "No lifecycle mapping for type '" + packaging + "': using defaults" );
+            mappings = defaultPhases;
         }
-    }
-
-    private void injectHandlerPluginConfiguration( MavenProject project, String groupId, String artifactId,
-                                                  String version )
-    {
-        String key = Plugin.constructKey( groupId, artifactId );
-        Plugin plugin = (Plugin) project.getBuild().getPluginsAsMap().get( key );
 
-        if ( plugin == null )
+        boolean finished = false;
+        for ( Iterator i = phases.iterator(); i.hasNext() && !finished; )
         {
-            plugin = new Plugin();
-            plugin.setGroupId( groupId );
-            plugin.setArtifactId( artifactId );
-            plugin.setVersion( version );
+            String phase = (String) i.next();
 
-            PluginManagement pluginManagement = project.getPluginManagement();
-            if ( pluginManagement != null )
+            String phaseTasks = (String) mappings.get( phase );
+
+            if ( phaseTasks != null )
             {
-                Plugin def = (Plugin) pluginManagement.getPluginsAsMap().get( key );
-                if ( def != null )
+                for ( StringTokenizer tok = new StringTokenizer( phaseTasks, "," ); tok.hasMoreTokens(); )
                 {
-                    modelDefaultsInjector.mergePluginWithDefaults( plugin, def );
+                    String goal = tok.nextToken().trim();
+
+                    MojoDescriptor mojoDescriptor = getMojoDescriptor( goal, session );
+                    addToPhaseMap( phaseMap, phase, new MojoExecution( mojoDescriptor ), session.getSettings() );
                 }
             }
 
-            project.addPlugin( plugin );
-        }
-    }
-
-    private void processPluginConfiguration( MavenProject project, MavenSession mavenSession, Map phaseMap,
-                                            Map goalInstanceMap )
-        throws LifecycleExecutionException, ArtifactResolutionException
-    {
-        for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
-        {
-            Plugin plugin = (Plugin) i.next();
-
-            processPluginPhases( plugin, mavenSession, phaseMap, goalInstanceMap );
+            if ( phase.equals( selectedPhase ) )
+            {
+                finished = true;
+            }
         }
     }
 
@@ -319,11 +240,46 @@
      * to execute for that given phase.
      *
      * @param session
-     * @param goalInstanceMap 
      */
-    private void processPluginPhases( Plugin plugin, MavenSession session, Map phaseMap, Map goalInstanceMap )
+    private void bindPluginToLifecycle( Plugin plugin, MavenSession session, Map phaseMap )
         throws LifecycleExecutionException, ArtifactResolutionException
     {
+        if ( plugin.getGoals() != null && !plugin.getGoals().isEmpty() )
+        {
+            getLogger().warn(
+                "DEPRECATED: goal definitions for plugin '" + plugin.getKey() + "' must be in an executions element" );
+        }
+
+        PluginDescriptor pluginDescriptor;
+        Settings settings = session.getSettings();
+
+        pluginDescriptor = verifyPlugin( plugin, session );
+
+        if ( pluginDescriptor.getMojos() != null && !pluginDescriptor.getMojos().isEmpty() )
+        {
+            // use the plugin if inherit was true in a base class, or it is in the current POM, otherwise use the default inheritence setting
+            if ( plugin.isInheritanceApplied() || pluginDescriptor.isInheritedByDefault() )
+            {
+                bindGoalMapToLifecycle( pluginDescriptor, plugin.getGoalsAsMap(), phaseMap, settings );
+
+                List executions = plugin.getExecutions();
+
+                if ( executions != null )
+                {
+                    for ( Iterator it = executions.iterator(); it.hasNext(); )
+                    {
+                        PluginExecution execution = (PluginExecution) it.next();
+
+                        bindExecutionToLifecycle( pluginDescriptor, phaseMap, execution, settings );
+                    }
+                }
+            }
+        }
+    }
+
+    private PluginDescriptor verifyPlugin( Plugin plugin, MavenSession session )
+        throws ArtifactResolutionException, LifecycleExecutionException
+    {
         String groupId = plugin.getGroupId();
 
         String artifactId = plugin.getArtifactId();
@@ -333,8 +289,10 @@
         PluginDescriptor pluginDescriptor;
         try
         {
-            pluginDescriptor = pluginManager.verifyPlugin( groupId, artifactId, version, session.getProject(), session
-                .getSettings(), session.getLocalRepository() );
+            MavenProject project = session.getProject();
+            ArtifactRepository localRepository = session.getLocalRepository();
+            pluginDescriptor = pluginManager.verifyPlugin( groupId, artifactId, version, project, session.getSettings(),
+                                                           localRepository );
         }
         catch ( PluginManagerException e )
         {
@@ -344,87 +302,80 @@
         {
             throw new LifecycleExecutionException( "Error resolving plugin version", e );
         }
+        return pluginDescriptor;
+    }
 
-        if ( plugin.isInheritanceApplied() || pluginDescriptor.isInheritedByDefault() )
+    /**
+     * @deprecated
+     */
+    private void bindGoalMapToLifecycle( PluginDescriptor pluginDescriptor, Map goalMap, Map phaseMap,
+                                         Settings settings )
+        throws LifecycleExecutionException
+    {
+        for ( Iterator i = pluginDescriptor.getMojos().iterator(); i.hasNext(); )
         {
-            processGoalContainerPhases( plugin, null, pluginDescriptor, session, plugin.getGoalsAsMap(), phaseMap,
-                                        goalInstanceMap );
+            MojoDescriptor mojoDescriptor = (MojoDescriptor) i.next();
 
-            List executions = plugin.getExecutions();
+            Goal goal = (Goal) goalMap.get( mojoDescriptor.getGoal() );
 
-            if ( executions != null )
+            if ( goal != null )
             {
-                for ( Iterator it = executions.iterator(); it.hasNext(); )
+                // We have to check to see that the inheritance rules have been applied before binding this mojo.
+                if ( mojoDescriptor.isInheritedByDefault() )
                 {
-                    PluginExecution execution = (PluginExecution) it.next();
-
-                    if ( execution.isInheritanceApplied() )
+                    if ( mojoDescriptor.getPhase() != null )
                     {
-                        processGoalContainerPhases( plugin, execution, pluginDescriptor, session, execution
-                            .getGoalsAsMap(), phaseMap, goalInstanceMap );
+                        MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
+                        addToPhaseMap( phaseMap, mojoDescriptor.getPhase(), mojoExecution, settings );
                     }
                 }
             }
         }
     }
 
-    private void processGoalContainerPhases( Plugin plugin, PluginExecution execution,
-                                            PluginDescriptor pluginDescriptor, MavenSession session, Map goalMap,
-                                            Map phaseMap, Map goalInstanceMap )
+    private void bindExecutionToLifecycle( PluginDescriptor pluginDescriptor, Map phaseMap, PluginExecution execution,
+                                           Settings settings )
         throws LifecycleExecutionException
     {
-        // ----------------------------------------------------------------------
-        // Look to see if the plugin configuration specifies particular mojos
-        // within the plugin. If this is the case then simply configure the
-        // mojos the user has specified and ignore the rest.
-        // ----------------------------------------------------------------------
-
-        if ( pluginDescriptor.getMojos() != null )
+        for ( Iterator i = execution.getGoals().iterator(); i.hasNext(); )
         {
-            for ( Iterator j = pluginDescriptor.getMojos().iterator(); j.hasNext(); )
-            {
-                MojoDescriptor mojoDescriptor = (MojoDescriptor) j.next();
-
-                // TODO: remove later
-                if ( mojoDescriptor.getGoal() == null )
-                {
-                    throw new LifecycleExecutionException( "The plugin " + pluginDescriptor.getId()
-                        + " was built with an older version of Maven" );
-                }
+            String goal = (String) i.next();
 
-                Goal goal = (Goal) goalMap.get( mojoDescriptor.getGoal() );
+            MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
+            if ( mojoDescriptor == null )
+            {
+                throw new LifecycleExecutionException( "Goal from the POM '" + goal + "' was not found in the plugin" );
+            }
 
-                if ( goalMap.isEmpty() )
+            // We have to check to see that the inheritance rules have been applied before binding this mojo.
+            if ( execution.isInheritanceApplied() || mojoDescriptor.isInheritedByDefault() )
+            {
+                MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, execution.getId() );
+                if ( execution.getPhase() != null )
                 {
-                    configureMojoPhaseBinding( mojoDescriptor, phaseMap, session.getSettings() );
-
-                    addToGoalInstanceMap( goalInstanceMap, new GoalInstance( plugin, execution, goal, mojoDescriptor ) );
+                    addToPhaseMap( phaseMap, execution.getPhase(), mojoExecution, settings );
                 }
-                else if ( goal != null )
+                else if ( mojoDescriptor.getPhase() != null )
                 {
-                    // We have to check to see that the inheritance rules have been applied before binding this mojo.
-                    if ( goal.isInheritanceApplied() || mojoDescriptor.isInheritedByDefault() )
-                    {
-                        configureMojoPhaseBinding( mojoDescriptor, phaseMap, session.getSettings() );
-
-                        addToGoalInstanceMap( goalInstanceMap, new GoalInstance( plugin, execution, goal,
-                                                                                 mojoDescriptor ) );
-                    }
+                    // if the phase was not in the configuration, use the phase in the descriptor
+                    addToPhaseMap( phaseMap, mojoDescriptor.getPhase(), mojoExecution, settings );
                 }
             }
         }
     }
 
-    /**
-     * Take a look at a mojo contained within a plugin, look to see whether it contributes to a
-     * phase in the lifecycle and if it does place it at the end of the list of goals
-     * to execute for the stated phase.
-     *
-     * @param mojoDescriptor
-     */
-    private void configureMojoPhaseBinding( MojoDescriptor mojoDescriptor, Map phaseMap, Settings settings )
+    private void addToPhaseMap( Map phaseMap, String phase, MojoExecution mojoExecution, Settings settings )
         throws LifecycleExecutionException
     {
+        List goals = (List) phaseMap.get( phase );
+
+        if ( goals == null )
+        {
+            String message = "Required phase '" + phase + "' not found";
+            throw new LifecycleExecutionException( message );
+        }
+
+        MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
         if ( settings.isOffline() && mojoDescriptor.isOnlineRequired() )
         {
             String goal = mojoDescriptor.getGoal();
@@ -432,128 +383,29 @@
         }
         else
         {
-            if ( mojoDescriptor.getPhase() != null )
-            {
-                addToPhaseMap( phaseMap, mojoDescriptor.getPhase(), mojoDescriptor );
-            }
+            goals.add( mojoExecution );
         }
     }
 
-    private void addToPhaseMap( Map phaseMap, String phase, MojoDescriptor mojoDescriptor )
-        throws LifecycleExecutionException
-    {
-        if ( phase != null )
-        {
-            List goals = (List) phaseMap.get( phase );
-
-            if ( goals == null )
-            {
-                String message = "Required phase '" + phase + "' not found";
-                throw new LifecycleExecutionException( message );
-            }
-
-            if ( !goals.contains( mojoDescriptor ) )
-            {
-                goals.add( mojoDescriptor );
-            }
-        }
-    }
-
-    private List processGoalChain( String task, MavenSession session, Map phaseMap )
-        throws LifecycleExecutionException, ArtifactResolutionException
+    private List processGoalChain( String task, Map phaseMap )
     {
         List goals = new ArrayList();
 
-        if ( phaseMap.containsKey( task ) )
-        {
-            // only execute up to the given phase
-            int index = phases.indexOf( task );
-
-            for ( int j = 0; j <= index; j++ )
-            {
-                String p = (String) phases.get( j );
-
-                List phaseGoals = (List) phaseMap.get( p );
+        // only execute up to the given phase
+        int index = phases.indexOf( task );
 
-                if ( phaseGoals != null )
-                {
-                    goals.addAll( phaseGoals );
-                }
-            }
-        }
-        else
+        for ( int i = 0; i <= index; i++ )
         {
-            MojoDescriptor mojoDescriptor = configureMojo( task, session, phaseMap );
-
-            goals.add( mojoDescriptor );
-        }
+            String p = (String) phases.get( i );
 
-        return goals;
-    }
-
-    private MojoDescriptor configureMojo( String task, MavenSession session, Map phaseMap )
-        throws LifecycleExecutionException, ArtifactResolutionException
-    {
-        MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session );
-
-        configureMojoPhaseBinding( mojoDescriptor, phaseMap, session.getSettings() );
+            List phaseGoals = (List) phaseMap.get( p );
 
-        return mojoDescriptor;
-    }
-
-    private List findMatchingGoalInstances( MojoDescriptor mojoDescriptor, MavenProject project )
-    {
-        PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
-
-        List plugins = project.getBuildPlugins();
-
-        List matchingSteps = new ArrayList();
-
-        Plugin plugin = null;
-
-        for ( Iterator it = plugins.iterator(); it.hasNext(); )
-        {
-            plugin = (Plugin) it.next();
-
-            if ( pluginDescriptor.getPluginLookupKey().equals( plugin.getKey() ) )
+            if ( phaseGoals != null )
             {
-                String mojoGoal = mojoDescriptor.getGoal();
-
-                Goal unattached = (Goal) plugin.getGoalsAsMap().get( mojoDescriptor.getGoal() );
-
-                if ( unattached != null )
-                {
-                    matchingSteps.add( new GoalInstance( plugin, unattached, mojoDescriptor ) );
-                }
-
-                List executions = plugin.getExecutions();
-
-                if ( executions != null )
-                {
-                    for ( Iterator executionIterator = executions.iterator(); executionIterator.hasNext(); )
-                    {
-                        PluginExecution execution = (PluginExecution) executionIterator.next();
-
-                        Goal attached = (Goal) execution.getGoalsAsMap().get( mojoDescriptor.getGoal() );
-
-                        if ( attached != null )
-                        {
-                            matchingSteps.add( new GoalInstance( plugin, execution, attached, mojoDescriptor ) );
-                        }
-                    }
-                }
-
-                break;
+                goals.addAll( phaseGoals );
             }
         }
-
-        // if nothing is configured, then we need to add a "fully detached" step...
-        if ( matchingSteps.isEmpty() )
-        {
-            matchingSteps.add( new GoalInstance( mojoDescriptor ) );
-        }
-
-        return matchingSteps;
+        return goals;
     }
 
     private MojoDescriptor getMojoDescriptor( String task, MavenSession session )
@@ -590,18 +442,17 @@
         }
         else
         {
-            String message = "Invalid task '" + task + "': you must specify a valid lifecycle phase, or"
-                + " a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal";
+            String message = "Invalid task '" + task + "': you must specify a valid lifecycle phase, or" +
+                " a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal";
             throw new LifecycleExecutionException( message );
         }
 
+        MavenProject project = session.getProject();
         if ( pluginDescriptor == null )
         {
             try
             {
-                injectHandlerPluginConfiguration( session.getProject(), groupId, artifactId, version );
-
-                pluginDescriptor = pluginManager.verifyPlugin( groupId, artifactId, version, session.getProject(),
+                pluginDescriptor = pluginManager.verifyPlugin( groupId, artifactId, version, project,
                                                                session.getSettings(), session.getLocalRepository() );
             }
             catch ( PluginManagerException e )
@@ -613,33 +464,11 @@
                 throw new LifecycleExecutionException( "Error resolving plugin version", e );
             }
         }
-        else
-        {
-            injectHandlerPluginConfiguration( session.getProject(), pluginDescriptor.getGroupId(), pluginDescriptor
-                .getArtifactId(), pluginDescriptor.getVersion() );
-        }
-
-        MojoDescriptor mojoDescriptor = null;
 
-        if ( pluginDescriptor.getMojos() != null )
-        {
-            // TODO: should be able to create a Map from this
-            for ( Iterator i = pluginDescriptor.getMojos().iterator(); i.hasNext() && mojoDescriptor == null; )
-            {
-                MojoDescriptor desc = (MojoDescriptor) i.next();
-                if ( desc.getGoal().equals( goal ) )
-                {
-                    mojoDescriptor = desc;
-                }
-            }
-        }
-        else
-        {
-            throw new LifecycleExecutionException( "The plugin " + pluginDescriptor.getGroupId() + ":"
-                + pluginDescriptor.getArtifactId() + ":" + pluginDescriptor.getVersion()
-                + " doesn't contain any mojo. Check if it isn't corrupted." );
-        }
+        injectHandlerPluginConfiguration( project, pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId(),
+                                          pluginDescriptor.getVersion() );
 
+        MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
         if ( mojoDescriptor == null )
         {
             throw new LifecycleExecutionException( "Required goal not found: " + task );
@@ -648,9 +477,30 @@
         return mojoDescriptor;
     }
 
-    public List getPhases()
+    private void injectHandlerPluginConfiguration( MavenProject project, String groupId, String artifactId,
+                                                   String version )
     {
-        return phases;
-    }
+        String key = Plugin.constructKey( groupId, artifactId );
+        Plugin plugin = (Plugin) project.getBuild().getPluginsAsMap().get( key );
+
+        if ( plugin == null )
+        {
+            plugin = new Plugin();
+            plugin.setGroupId( groupId );
+            plugin.setArtifactId( artifactId );
+            plugin.setVersion( version );
 
+            PluginManagement pluginManagement = project.getPluginManagement();
+            if ( pluginManagement != null )
+            {
+                Plugin def = (Plugin) pluginManagement.getPluginsAsMap().get( key );
+                if ( def != null )
+                {
+                    modelDefaultsInjector.mergePluginWithDefaults( plugin, def );
+                }
+            }
+
+            project.addPlugin( plugin );
+        }
+    }
 }

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java?rev=191285&r1=191284&r2=191285&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java Sat Jun 18 06:01:26 2005
@@ -32,5 +32,4 @@
     MavenExecutionResponse execute( List tasks, MavenSession session )
         throws LifecycleExecutionException;
 
-    List getPhases();
 }

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=191285&r1=191284&r2=191285&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Sat Jun 18 06:01:26 2005
@@ -346,12 +346,12 @@
     // Mojo execution
     // ----------------------------------------------------------------------
 
-    public void executeMojo( MavenSession session, GoalInstance goalInstance )
+    public void executeMojo( MojoExecution mojoExecution, MavenSession session )
         throws ArtifactResolutionException, PluginManagerException, MojoExecutionException
     {
         PlexusContainer pluginContainer = null;
 
-        MojoDescriptor mojoDescriptor = goalInstance.getMojoDescriptor();
+        MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
 
         if ( mojoDescriptor.isDependencyResolutionRequired() != null )
         {
@@ -409,11 +409,13 @@
             plugin = (Mojo) pluginContainer.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() );
             plugin.setLog( mojoLogger );
 
-            String goalId = goalInstance.getGoalId();
-
             PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
 
-            Xpp3Dom dom = goalInstance.getCalculatedConfiguration();
+            String goalId = mojoDescriptor.getGoal();
+            String groupId = pluginDescriptor.getGroupId();
+            String artifactId = pluginDescriptor.getArtifactId();
+            String executionId = mojoExecution.getExecutionId();
+            Xpp3Dom dom = session.getProject().getGoalConfiguration( groupId, artifactId, executionId, goalId );
 
             PlexusConfiguration pomConfiguration;
             if ( dom == null )
@@ -451,9 +453,9 @@
 
             String goalExecId = goalName;
 
-            if ( goalInstance.getExecutionId() != null )
+            if ( mojoExecution.getExecutionId() != null )
             {
-                goalExecId += " {execution: " + goalInstance.getExecutionId() + "}";
+                goalExecId += " {execution: " + mojoExecution.getExecutionId() + "}";
             }
 
             dispatcher.dispatchStart( event, goalExecId );

Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java?rev=191285&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java Sat Jun 18 06:01:26 2005
@@ -0,0 +1,54 @@
+package org.apache.maven.plugin;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+
+/**
+ * Describes a single mojo invocation.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class MojoExecution
+{
+    private final String executionId;
+
+    private final MojoDescriptor mojoDescriptor;
+
+    public MojoExecution( MojoDescriptor mojoDescriptor )
+    {
+        this.mojoDescriptor = mojoDescriptor;
+        this.executionId = null;
+    }
+
+    public MojoExecution( MojoDescriptor mojoDescriptor, String executionId )
+    {
+        this.mojoDescriptor = mojoDescriptor;
+        this.executionId = executionId;
+    }
+
+    public String getExecutionId()
+    {
+        return executionId;
+    }
+
+    public MojoDescriptor getMojoDescriptor()
+    {
+        return mojoDescriptor;
+    }
+}

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java?rev=191285&r1=191284&r2=191285&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java Sat Jun 18 06:01:26 2005
@@ -32,7 +32,7 @@
 {
     String ROLE = PluginManager.class.getName();
 
-    void executeMojo( MavenSession session, GoalInstance buildStep )
+    void executeMojo( MojoExecution execution, MavenSession session )
         throws MojoExecutionException, PluginManagerException, ArtifactResolutionException;
 
     PluginDescriptor verifyPlugin( String prefix );

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java?rev=191285&r1=191284&r2=191285&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java Sat Jun 18 06:01:26 2005
@@ -145,7 +145,12 @@
         
         // determines what should be done if we're in non-interactive mode.
         // if true, then just update the registry with the new versions.
-        boolean autoUpdate = Boolean.valueOf( pluginRegistry.getAutoUpdate() ).booleanValue();
+        String s = getPluginRegistry( groupId, artifactId ).getAutoUpdate();
+        boolean autoUpdate = true;
+        if ( s != null )
+        {
+            autoUpdate = Boolean.valueOf( s ).booleanValue();
+        }
 
         // We should persist by default if:
         // 1. we detected a change in the plugin version from what was in the registry, or

Modified: maven/components/trunk/maven-model/maven.mdo
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-model/maven.mdo?rev=191285&r1=191284&r2=191285&view=diff
==============================================================================
--- maven/components/trunk/maven-model/maven.mdo (original)
+++ maven/components/trunk/maven-model/maven.mdo Sat Jun 18 06:01:26 2005
@@ -625,6 +625,14 @@
           <comment>These should ultimately only be compile time dependencies when transitive dependencies come into play.</comment>
         </field>
         <field>
+          <name>reports</name>
+          <version>4.0.0</version>
+          <description><![CDATA[
+            NOT A VALID ELEMENT. LISTED TO ALLOW LEGACY REPOSITORY POMs TO PARSE.
+          ]]></description>
+          <type>DOM</type>
+        </field>
+        <field>
           <name>reporting</name>
           <version>4.0.0</version>
           <description><![CDATA[
@@ -2013,7 +2021,7 @@
         </codeSegment>
       </codeSegments>
     </class>
-    <!--@todo find better solution for managment of site deployments -->
+    <!--@todo find better solution for management of site deployments -->
     <class>
       <name>Site</name>
       <version>4.0.0</version>
@@ -2049,40 +2057,8 @@
       </fields>
     </class>
 
-    <!--
-
-    A sketch of what a plugin configuration might look like where
-    we have plugin wide parameters that apply to all goals/mojos
-    and goal/mojo specific parameters that will override any
-    of the plugin wide definitions.
-
-    At first the configuration element will be a flat set of properties
-    but i would like the configuration to actually be an arbiitrary
-    data model or a simple DOM like structure so that mojos can
-    be arbitrarily configured in the same fashion plexus plugins
-    are configured.
-
-    <plugins>
-      <plugin>
-        <id>plexus</id>
-        <configuration>
-          <key>value</key>
-        </configuration>
-        <goals>
-          <goal>
-            <id></id>
-            <configuration>
-              <key>value</key>
-            </configuration>
-          </goal>
-        </goals>
-      </plugin>
-    </plugins>
-
-    -->
-
     <class>
-      <name>GoalContainer</name>
+      <name>ConfigurationContainer</name>
       <version>4.0.0</version>
       <fields>
         <field>
@@ -2095,20 +2071,11 @@
           <name>configuration</name>
           <type>DOM</type>
         </field>
-        <field>
-          <name>goals</name>
-          <version>4.0.0</version>
-          <association>
-            <type>Goal</type>
-            <multiplicity>*</multiplicity>
-          </association>
-        </field>
       </fields>
       <codeSegments>
         <codeSegment>
           <version>4.0.0</version>
           <code><![CDATA[
-    private Map goalMap = null;
     private boolean inheritanceApplied = true;
     
     public void unsetInheritanceApplied()
@@ -2120,28 +2087,6 @@
     {
         return inheritanceApplied;
     }
-    
-    public void flushGoalMap()
-    {
-        this.goalMap = null;
-    }
-
-    public Map getGoalsAsMap()
-    {
-        if ( goalMap == null )
-        {
-            goalMap = new HashMap();
-            if ( goals != null )
-            {
-                for ( Iterator i = goals.iterator(); i.hasNext(); )
-                {
-                    Goal g = (Goal) i.next();
-                    goalMap.put( g.getId(), g );
-                }
-            }
-        }
-        return goalMap;
-    }
           ]]></code>
         </codeSegment>
       </codeSegments>
@@ -2149,7 +2094,7 @@
     <class>
       <name>Plugin</name>
       <version>4.0.0</version>
-      <superClass>GoalContainer</superClass>
+      <superClass>ConfigurationContainer</superClass>
       <fields>
         <field>
           <name>groupId</name>
@@ -2179,6 +2124,15 @@
             <multiplicity>*</multiplicity>
           </association>
         </field>
+        <!-- TODO: this is deprecated -->
+        <field>
+          <name>goals</name>
+          <version>4.0.0</version>
+          <association>
+            <type>Goal</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
       </fields>
       <codeSegments>
         <codeSegment>
@@ -2218,6 +2172,32 @@
     {
         return groupId + ":" + artifactId;
     }
+
+    /** @deprecated */
+    private Map goalMap = null;
+    /** @deprecated */
+    public void flushGoalMap()
+    {
+        this.goalMap = null;
+    }
+
+    /** @deprecated */
+    public Map getGoalsAsMap()
+    {
+        if ( goalMap == null )
+        {
+            goalMap = new HashMap();
+            if ( goals != null )
+            {
+                for ( Iterator i = goals.iterator(); i.hasNext(); )
+                {
+                    Goal g = (Goal) i.next();
+                    goalMap.put( g.getId(), g );
+                }
+            }
+        }
+        return goalMap;
+    }
           ]]></code>
         </codeSegment>
       </codeSegments>
@@ -2225,7 +2205,7 @@
     <class>
       <name>PluginExecution</name>
       <version>4.0.0</version>
-      <superClass>GoalContainer</superClass>
+      <superClass>ConfigurationContainer</superClass>
       <fields>
         <field>
           <name>id</name>
@@ -2233,8 +2213,22 @@
           <required>true</required>
           <type>String</type>
         </field>
+        <field>
+          <name>phase</name>
+          <version>4.0.0</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>goals</name>
+          <version>4.0.0</version>
+          <association>
+            <type>String</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
       </fields>
     </class>
+    <!-- TODO: deprecated -->
     <class>
       <name>Goal</name>
       <version>4.0.0</version>
@@ -2245,33 +2239,10 @@
           <type>String</type>
         </field>
         <field>
-          <name>inherited</name>
-          <version>4.0.0</version>
-          <description><![CDATA[Whether this goal configuration should be propagated to child POMs.]]></description>
-          <type>String</type>
-        </field>
-        <field>
           <name>configuration</name>
           <type>DOM</type>
         </field>
       </fields>
-      <codeSegments>
-        <codeSegment>
-          <code><![CDATA[
-    private boolean inheritanceApplied = true;
-    
-    public void unsetInheritanceApplied()
-    {
-        this.inheritanceApplied = false;
-    }
-    
-    public boolean isInheritanceApplied()
-    {
-        return inheritanceApplied;
-    }
-          ]]></code>
-        </codeSegment>
-      </codeSegments>
     </class>
     <class>
       <name>DependencyManagement</name>

Modified: maven/components/trunk/maven-model/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-model/pom.xml?rev=191285&r1=191284&r2=191285&view=diff
==============================================================================
--- maven/components/trunk/maven-model/pom.xml (original)
+++ maven/components/trunk/maven-model/pom.xml Sat Jun 18 06:01:26 2005
@@ -20,8 +20,7 @@
       <plugin>
         <groupId>org.codehaus.modello</groupId>
         <artifactId>modello-maven-plugin</artifactId>
-        <version>1.0-alpha-2</version>
-        <!-- version>1.0-alpha-3-SNAPSHOT</version -->
+        <version>1.0-alpha-3-SNAPSHOT</version>
         <configuration>
           <version>4.0.0</version>
           <model>maven.mdo</model>

Modified: maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java?rev=191285&r1=191284&r2=191285&view=diff
==============================================================================
--- maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java (original)
+++ maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java Sat Jun 18 06:01:26 2005
@@ -19,6 +19,7 @@
 import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
 
 import java.util.List;
+import java.util.Iterator;
 
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@@ -40,7 +41,7 @@
     private String source;
 
     private boolean inheritedByDefault = true;
-    
+
     private List artifacts;
 
     // ----------------------------------------------------------------------
@@ -55,7 +56,8 @@
     public void addMojo( MojoDescriptor mojoDescriptor )
         throws DuplicateMojoDescriptorException
     {
-        // this relies heavily on the equals() and hashCode() for ComponentDescriptor, 
+        MojoDescriptor existing = null;
+        // this relies heavily on the equals() and hashCode() for ComponentDescriptor,
         // which uses role:roleHint for identity...and roleHint == goalPrefix:goal.
         // role does not vary for Mojos.
         List mojos = getComponents();
@@ -64,8 +66,11 @@
         {
             int indexOf = mojos.indexOf( mojoDescriptor );
 
-            MojoDescriptor existing = (MojoDescriptor) mojos.get( indexOf );
+            existing = (MojoDescriptor) mojos.get( indexOf );
+        }
 
+        if ( existing != null )
+        {
             throw new DuplicateMojoDescriptorException( getGoalPrefix(), mojoDescriptor.getGoal(), existing
                 .getImplementation(), mojoDescriptor.getImplementation() );
         }
@@ -191,7 +196,7 @@
     {
         this.inheritedByDefault = inheritedByDefault;
     }
-    
+
     public List getArtifacts()
     {
         return artifacts;
@@ -215,5 +220,22 @@
     public int hashCode()
     {
         return 10 + getId().hashCode();
+    }
+
+    public MojoDescriptor getMojo( String goal )
+    {
+        // TODO: could we use a map? Maybe if the parent did that for components too, as this is too vulnerable to
+        // changes above not being propogated to the map
+
+        MojoDescriptor mojoDescriptor = null;
+        for ( Iterator i = getMojos().iterator(); i.hasNext() && mojoDescriptor == null; )
+        {
+            MojoDescriptor desc = (MojoDescriptor) i.next();
+            if ( goal.equals( desc.getGoal() ) )
+            {
+                mojoDescriptor = desc;
+            }
+        }
+        return mojoDescriptor;
     }
 }

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java?rev=191285&r1=191284&r2=191285&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java Sat Jun 18 06:01:26 2005
@@ -27,6 +27,7 @@
 import org.apache.maven.model.DependencyManagement;
 import org.apache.maven.model.Developer;
 import org.apache.maven.model.DistributionManagement;
+import org.apache.maven.model.Goal;
 import org.apache.maven.model.IssueManagement;
 import org.apache.maven.model.License;
 import org.apache.maven.model.MailingList;
@@ -36,6 +37,8 @@
 import org.apache.maven.model.PluginManagement;
 import org.apache.maven.model.Reporting;
 import org.apache.maven.model.Scm;
+import org.apache.maven.model.PluginExecution;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -877,5 +880,68 @@
             attachedArtifacts = new ArrayList();
         }
         return attachedArtifacts;
+    }
+
+    public Xpp3Dom getGoalConfiguration( String pluginGroupId, String pluginArtifactId, String executionId,
+                                         String goalId )
+    {
+        Xpp3Dom dom = null;
+
+        // ----------------------------------------------------------------------
+        // I would like to be able to lookup the Mojo object using a key but
+        // we have a limitation in modello that will be remedied shortly. So
+        // for now I have to iterate through and see what we have.
+        // ----------------------------------------------------------------------
+
+        if ( getBuildPlugins() != null )
+        {
+            for ( Iterator iterator = getBuildPlugins().iterator(); iterator.hasNext(); )
+            {
+                Plugin plugin = (Plugin) iterator.next();
+
+                if ( pluginGroupId.equals( plugin.getGroupId() ) && pluginArtifactId.equals( plugin.getArtifactId() ) )
+                {
+                    dom = (Xpp3Dom) plugin.getConfiguration();
+
+                    // TODO: this part is deprecated
+                    if ( goalId != null )
+                    {
+                        Goal goal = (Goal) plugin.getGoalsAsMap().get( goalId );
+                        if ( goal != null )
+                        {
+                            Xpp3Dom goalConfiguration = (Xpp3Dom) goal.getConfiguration();
+                            if ( goalConfiguration != null )
+                            {
+                                Xpp3Dom newDom = new Xpp3Dom( goalConfiguration );
+                                dom = Xpp3Dom.mergeXpp3Dom( newDom, dom );
+                            }
+                        }
+                    }
+
+                    if ( executionId != null )
+                    {
+                        PluginExecution execution = (PluginExecution) plugin.getExecutionsAsMap().get( executionId );
+                        if ( execution != null )
+                        {
+                            Xpp3Dom executionConfiguration = (Xpp3Dom) execution.getConfiguration();
+                            if ( executionConfiguration != null )
+                            {
+                                Xpp3Dom newDom = new Xpp3Dom( executionConfiguration );
+                                dom = Xpp3Dom.mergeXpp3Dom( newDom, dom );
+                            }
+                        }
+                    }
+                    break;
+                }
+            }
+        }
+
+        if ( dom != null )
+        {
+            // make a copy so the original in the POM doesn't get messed with
+            dom = new Xpp3Dom( dom );
+        }
+
+        return dom;
     }
 }

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java?rev=191285&r1=191284&r2=191285&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java Sat Jun 18 06:01:26 2005
@@ -1,7 +1,6 @@
 package org.apache.maven.project;
 
 import org.apache.maven.model.Goal;
-import org.apache.maven.model.GoalContainer;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.PluginContainer;
 import org.apache.maven.model.PluginExecution;
@@ -31,9 +30,8 @@
 
 public final class ModelUtils
 {
-
     public static void mergePluginLists( PluginContainer childContainer, PluginContainer parentContainer,
-                                        boolean handleAsInheritance )
+                                         boolean handleAsInheritance )
     {
         if ( childContainer == null || parentContainer == null )
         {
@@ -55,8 +53,8 @@
 
                 String parentInherited = parentPlugin.getInherited();
 
-                if ( !handleAsInheritance || parentInherited == null
-                    || Boolean.valueOf( parentInherited ).booleanValue() )
+                if ( !handleAsInheritance || parentInherited == null ||
+                    Boolean.valueOf( parentInherited ).booleanValue() )
                 {
 
                     Plugin assembledPlugin = parentPlugin;
@@ -109,7 +107,7 @@
         }
 
         // merge the lists of goals that are not attached to an <execution/>
-        ModelUtils.mergeGoalContainerDefinitions( child, parent, handleAsInheritance );
+        ModelUtils.mergeGoalContainerDefinitions( child, parent );
 
         // from here to the end of the method is dealing with merging of the <executions/> section.
         String parentInherited = parent.getInherited();
@@ -136,7 +134,7 @@
 
                     if ( childExecution != null )
                     {
-                        ModelUtils.mergeGoalContainerDefinitions( childExecution, parentExecution, handleAsInheritance );
+                        ModelUtils.mergePluginExecutionDefinitions( childExecution, parentExecution );
 
                         assembled = childExecution;
                     }
@@ -168,8 +166,12 @@
 
     }
 
-    private static void mergeGoalContainerDefinitions( GoalContainer child, GoalContainer parent,
-                                                      boolean handleAsInheritance )
+    /**
+     * @param child
+     * @param parent
+     * @deprecated
+     */
+    private static void mergeGoalContainerDefinitions( Plugin child, Plugin parent )
     {
         List parentGoals = parent.getGoals();
 
@@ -186,33 +188,23 @@
                 {
                     Goal parentGoal = (Goal) it.next();
 
-                    String parentInherited = parentGoal.getInherited();
-
-                    if ( !handleAsInheritance || parentInherited == null
-                        || Boolean.valueOf( parentInherited ).booleanValue() )
-                    {
-                        Goal assembledGoal = parentGoal;
-
-                        Goal childGoal = (Goal) childGoals.get( parentGoal.getId() );
+                    Goal assembledGoal = parentGoal;
 
-                        if ( childGoal != null )
-                        {
-                            Xpp3Dom childGoalConfig = (Xpp3Dom) childGoal.getConfiguration();
-                            Xpp3Dom parentGoalConfig = (Xpp3Dom) parentGoal.getConfiguration();
+                    Goal childGoal = (Goal) childGoals.get( parentGoal.getId() );
 
-                            childGoalConfig = Xpp3Dom.mergeXpp3Dom( childGoalConfig, parentGoalConfig );
+                    if ( childGoal != null )
+                    {
+                        Xpp3Dom childGoalConfig = (Xpp3Dom) childGoal.getConfiguration();
+                        Xpp3Dom parentGoalConfig = (Xpp3Dom) parentGoal.getConfiguration();
 
-                            childGoal.setConfiguration( childGoalConfig );
+                        childGoalConfig = Xpp3Dom.mergeXpp3Dom( childGoalConfig, parentGoalConfig );
 
-                            assembledGoal = childGoal;
-                        }
-                        else if ( handleAsInheritance && parentInherited == null )
-                        {
-                            assembledGoal.unsetInheritanceApplied();
-                        }
+                        childGoal.setConfiguration( childGoalConfig );
 
-                        assembledGoals.put( assembledGoal.getId(), assembledGoal );
+                        assembledGoal = childGoal;
                     }
+
+                    assembledGoals.put( assembledGoal.getId(), assembledGoal );
                 }
 
                 for ( Iterator it = childGoals.entrySet().iterator(); it.hasNext(); )
@@ -242,4 +234,27 @@
         child.setConfiguration( childConfiguration );
     }
 
+    private static void mergePluginExecutionDefinitions( PluginExecution child, PluginExecution parent )
+    {
+        List parentGoals = parent.getGoals();
+
+        // if the supplemental goals are non-existent, then nothing related to goals changes.
+        if ( parentGoals != null && !parentGoals.isEmpty() )
+        {
+            List goals = new ArrayList( parentGoals );
+            if ( child.getGoals() != null )
+            {
+                goals.addAll( child.getGoals() );
+            }
+
+            child.setGoals( goals );
+        }
+
+        Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration();
+        Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration();
+
+        childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration );
+
+        child.setConfiguration( childConfiguration );
+    }
 }

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java?rev=191285&r1=191284&r2=191285&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java Sat Jun 18 06:01:26 2005
@@ -57,7 +57,7 @@
         {
             return;
         }
-        
+
         // Group id
         if ( child.getGroupId() == null )
         {
@@ -156,7 +156,7 @@
     public void mergeProfileWithModel( Model model, Profile profile )
     {
         assembleModelBaseInheritance( model, profile );
-        
+
         assembleBuildBaseInheritance( model.getBuild(), profile.getBuild() );
     }
 
@@ -262,10 +262,10 @@
             }
 
             childReporting.setPlugins( new ArrayList( mergedReportPlugins.values() ) );
-            
+
             childReporting.flushReportPluginMap();
         }
-        
+
         assembleDependencyManagementInheritance( child, parent );
     }
 
@@ -352,7 +352,7 @@
         }
 
         dominant.setReportSets( new ArrayList( mergedReportSets.values() ) );
-        
+
         dominant.flushReportSetMap();
     }
 
@@ -398,7 +398,7 @@
         {
             return;
         }
-        
+
         Build childBuild = child.getBuild();
 
         if ( parentBuild != null )
@@ -408,9 +408,9 @@
                 childBuild = new Build();
                 child.setBuild( childBuild );
             }
+            
             // The build has been set but we want to step in here and fill in
-            // values
-            // that have not been set by the child.
+            // values that have not been set by the child.
 
             if ( childBuild.getDirectory() == null )
             {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org