You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2007/03/20 22:41:05 UTC

svn commit: r520609 [2/3] - in /maven/components/trunk: ./ maven-build-context/src/main/java/org/apache/maven/context/ maven-core/ maven-core/src/main/java/org/apache/maven/ maven-core/src/main/java/org/apache/maven/execution/ maven-core/src/main/java/...

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?view=diff&rev=520609&r1=520608&r2=520609
==============================================================================
--- 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 Tue Mar 20 14:40:59 2007
@@ -25,13 +25,16 @@
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.context.BuildContextManager;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.execution.ReactorManager;
-import org.apache.maven.lifecycle.mapping.LifecycleMapping;
+import org.apache.maven.lifecycle.binding.LifecycleBindingManager;
+import org.apache.maven.lifecycle.binding.MojoBindingFactory;
+import org.apache.maven.lifecycle.model.MojoBinding;
+import org.apache.maven.lifecycle.plan.BuildPlan;
+import org.apache.maven.lifecycle.plan.BuildPlanUtils;
+import org.apache.maven.lifecycle.plan.BuildPlanner;
 import org.apache.maven.model.Plugin;
-import org.apache.maven.model.PluginExecution;
-import org.apache.maven.model.ReportPlugin;
-import org.apache.maven.model.ReportSet;
 import org.apache.maven.monitor.event.EventDispatcher;
 import org.apache.maven.monitor.event.MavenEvents;
 import org.apache.maven.plugin.InvalidPluginException;
@@ -44,29 +47,22 @@
 import org.apache.maven.plugin.PluginNotFoundException;
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
-import org.apache.maven.plugin.lifecycle.Execution;
-import org.apache.maven.plugin.lifecycle.Phase;
+import org.apache.maven.plugin.loader.PluginLoader;
+import org.apache.maven.plugin.loader.PluginLoaderException;
 import org.apache.maven.plugin.version.PluginVersionNotFoundException;
 import org.apache.maven.plugin.version.PluginVersionResolutionException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
-import org.apache.maven.reporting.MavenReport;
-import org.apache.maven.settings.Settings;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Stack;
-import java.util.StringTokenizer;
 
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@@ -84,14 +80,18 @@
     // ----------------------------------------------------------------------
 
     private PluginManager pluginManager;
-
-    private List lifecycles;
+    
+    private PluginLoader pluginLoader;
+    
+    private BuildPlanner buildPlanner;
 
     private ArtifactHandlerManager artifactHandlerManager;
 
-    private List defaultReports;
+    private MojoBindingFactory mojoBindingFactory;
+
+    private LifecycleBindingManager lifecycleBindingManager;
 
-    private Map phaseToLifecycleMap;
+    private BuildContextManager buildContextManager;
 
     // ----------------------------------------------------------------------
     //
@@ -165,26 +165,41 @@
                     getLogger().info( "  " + segment );
 
                     line();
+                    
+                    String target = rootProject.getId() + " ( " + segment + " )";
 
+                    getLogger().debug( "Constructing build plan for " + target );
+                    
                     // !! This is ripe for refactoring to an aspect.
                     // Event monitoring.
                     String event = MavenEvents.PROJECT_EXECUTION;
 
                     long buildStartTime = System.currentTimeMillis();
 
-                    String target = rootProject.getId() + " ( " + segment + " )";
-
                     dispatcher.dispatchStart( event, target );
 
+                    // NEW: To support forked execution under the new lifecycle architecture, the current project
+                    // is stored in a build-context managed data type. This context type holds the current project
+                    // for the fork being executed, plus a stack of projects used in the ancestor execution contexts.
+                    LifecycleExecutionContext ctx = new LifecycleExecutionContext( rootProject );
+                    ctx.store( buildContextManager );
+                    
+                    // NEW: Build up the execution plan, including configuration.
+                    List mojoBindings = getLifecycleBindings( segment.getTasks(), rootProject, target );
+                    
+                    // NEW: Then, iterate over each binding in that plan, and execute the associated mojo.
                     // only call once, with the top-level project (assumed to be provided as a parameter)...
-                    for ( Iterator goalIterator = segment.getTasks().iterator(); goalIterator.hasNext(); )
+                    for ( Iterator mojoIterator = mojoBindings.iterator(); mojoIterator.hasNext(); )
                     {
-                        String task = (String) goalIterator.next();
+                        MojoBinding binding = (MojoBinding) mojoIterator.next();
 
-                        executeGoalAndHandleFailures( task, session, rootProject, dispatcher, event, rm, buildStartTime,
+                        executeGoalAndHandleFailures( binding, session, dispatcher, event, rm, buildStartTime,
                                                       target );
                     }
-
+                    
+                    // clean up the execution context, so we don't pollute for future project-executions.
+                    LifecycleExecutionContext.delete( buildContextManager );
+                    
                     rm.registerBuildSuccess( rootProject, System.currentTimeMillis() - buildStartTime );
 
                     dispatcher.dispatchEnd( event, target );
@@ -222,23 +237,32 @@
 
                         line();
 
+                        String target = currentProject.getId() + " ( " + segment + " )";
+                        
                         // !! This is ripe for refactoring to an aspect.
                         // Event monitoring.
                         String event = MavenEvents.PROJECT_EXECUTION;
 
                         long buildStartTime = System.currentTimeMillis();
 
-                        String target = currentProject.getId() + " ( " + segment + " )";
                         dispatcher.dispatchStart( event, target );
-
-                        for ( Iterator goalIterator = segment.getTasks().iterator(); goalIterator.hasNext(); )
+                        
+                        LifecycleExecutionContext ctx = new LifecycleExecutionContext( currentProject );
+                        ctx.store( buildContextManager );
+
+                        List mojoBindings = getLifecycleBindings( segment.getTasks(), currentProject, target );
+                        
+                        for ( Iterator mojoIterator = mojoBindings.iterator(); mojoIterator.hasNext(); )
                         {
-                            String task = (String) goalIterator.next();
+                            MojoBinding mojoBinding = (MojoBinding) mojoIterator.next();
 
-                            executeGoalAndHandleFailures( task, session, currentProject, dispatcher, event, rm,
+                            getLogger().debug( "Mojo: " + mojoBinding.getGoal() + " has config:\n" + mojoBinding.getConfiguration() );
+                            executeGoalAndHandleFailures( mojoBinding, session, dispatcher, event, rm,
                                                           buildStartTime, target );
                         }
 
+                        LifecycleExecutionContext.delete( buildContextManager );
+                        
                         rm.registerBuildSuccess( currentProject, System.currentTimeMillis() - buildStartTime );
 
                         dispatcher.dispatchEnd( event, target );
@@ -261,20 +285,120 @@
         }
     }
 
-    private void executeGoalAndHandleFailures( String task, MavenSession session, MavenProject project,
-                                               EventDispatcher dispatcher, String event, ReactorManager rm,
+    /**
+     * Retrieves the build plan for the current project, given the specified list of tasks. This
+     * build plan will consist of MojoBindings, each fully configured to execute, which enables us
+     * to enumerate the full build plan to the debug log-level, complete with the configuration each
+     * mojo will use.
+     */
+    private List getLifecycleBindings( List tasks, MavenProject project, String targetDescription )
+        throws LifecycleExecutionException
+    {
+        List mojoBindings;
+        try
+        {
+            BuildPlan plan = buildPlanner.constructBuildPlan( tasks, project );
+            
+            if ( getLogger().isDebugEnabled() )
+            {
+                getLogger().debug( "\n\nOur build plan is:\n" + BuildPlanUtils.listBuildPlan( plan, project, lifecycleBindingManager, false ) + "\n\n" );
+            }
+            
+            mojoBindings = plan.getPlanMojoBindings( project, lifecycleBindingManager );
+        }
+        catch ( LifecycleException e )
+        {
+            throw new LifecycleExecutionException( "Failed to construct build plan for: " + targetDescription + ". Reason: "
+                + e.getMessage(), e );
+        }
+        
+        return mojoBindings;
+    }
+
+    private void executeGoalAndHandleFailures( MojoBinding mojoBinding, MavenSession session, EventDispatcher dispatcher, String event, ReactorManager rm,
                                                long buildStartTime, String target )
         throws BuildFailureException, LifecycleExecutionException
     {
+        // NEW: Retrieve/use the current project stored in the execution context, for consistency.
+        LifecycleExecutionContext ctx = LifecycleExecutionContext.read( buildContextManager );
+        MavenProject project = ctx.getCurrentProject();
+        
+        // NEW: Since the MojoBinding instances are configured when the build plan is constructed,
+        // all that remains to be done here is to load the PluginDescriptor, construct a MojoExecution
+        // instance, and call PluginManager.executeMojo( execution ). The MojoExecutor is constructed
+        // using both the PluginDescriptor and the MojoBinding.
         try
         {
-            executeGoal( task, session, project );
+            PluginDescriptor pluginDescriptor = null;
+            try
+            {
+                pluginDescriptor = pluginLoader.loadPlugin( mojoBinding, project );
+            }
+            catch ( PluginLoaderException e )
+            {
+                if ( mojoBinding.isOptional() )
+                {
+                    getLogger().debug( "Skipping optional mojo execution: " + MojoBindingUtils.toString( mojoBinding ) );
+                }
+                else
+                {
+                    throw new LifecycleExecutionException( "Failed to load plugin for: " + MojoBindingUtils.toString( mojoBinding )
+                                                           + ". Reason: " + e.getMessage(), e );
+                }
+            }
+            
+            if ( pluginDescriptor != null )
+            {
+                MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( mojoBinding.getGoal() );
+                MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
+                
+                mojoExecution.setConfiguration( (Xpp3Dom) mojoBinding.getConfiguration() );
+
+                try
+                {
+                    pluginManager.executeMojo( project, mojoExecution, session );
+                }
+                catch ( PluginManagerException e )
+                {
+                    throw new LifecycleExecutionException( "Internal error in the plugin manager executing goal '" +
+                        mojoDescriptor.getId() + "': " + e.getMessage(), e );
+                }
+                catch ( ArtifactNotFoundException e )
+                {
+                    throw new LifecycleExecutionException( e.getMessage(), e );
+                }
+                catch ( InvalidDependencyVersionException e )
+                {
+                    throw new LifecycleExecutionException( e.getMessage(), e );
+                }
+                catch ( ArtifactResolutionException e )
+                {
+                    throw new LifecycleExecutionException( e.getMessage(), e );
+                }
+                catch ( MojoFailureException e )
+                {
+                    throw new BuildFailureException( e.getMessage(), e );
+                }
+                catch ( MojoExecutionException e )
+                {
+                    throw new LifecycleExecutionException( e.getMessage(), e );
+                }
+                catch ( PluginConfigurationException e )
+                {
+                    throw new LifecycleExecutionException( e.getMessage(), e );
+                }
+            }
+            else
+            {
+                throw new LifecycleExecutionException( "Failed to load plugin for: " + MojoBindingUtils.toString( mojoBinding )
+                                                       + ". Reason: unknown" );
+            }
         }
         catch ( LifecycleExecutionException e )
         {
             dispatcher.dispatchError( event, target, e );
 
-            if ( handleExecutionFailure( rm, project, e, task, buildStartTime ) )
+            if ( handleExecutionFailure( rm, project, e, mojoBinding, buildStartTime ) )
             {
                 throw e;
             }
@@ -283,17 +407,17 @@
         {
             dispatcher.dispatchError( event, target, e );
 
-            if ( handleExecutionFailure( rm, project, e, task, buildStartTime ) )
+            if ( handleExecutionFailure( rm, project, e, mojoBinding, buildStartTime ) )
             {
                 throw e;
             }
         }
     }
 
-    private boolean handleExecutionFailure( ReactorManager rm, MavenProject project, Exception e, String task,
+    private boolean handleExecutionFailure( ReactorManager rm, MavenProject project, Exception e, MojoBinding mojoBinding,
                                             long buildStartTime )
     {
-        rm.registerBuildFailure( project, e, task, System.currentTimeMillis() - buildStartTime );
+        rm.registerBuildFailure( project, e, MojoBindingUtils.toString( mojoBinding ), System.currentTimeMillis() - buildStartTime );
 
         if ( ReactorManager.FAIL_FAST.equals( rm.getFailureBehavior() ) )
         {
@@ -307,12 +431,12 @@
         return false;
     }
 
-    private List segmentTaskListByAggregationNeeds( List tasks, MavenSession session, MavenProject project )
+    private List segmentTaskListByAggregationNeeds( List tasks, MavenSession session, MavenProject rootProject )
         throws LifecycleExecutionException, BuildFailureException
     {
         List segments = new ArrayList();
 
-        if ( project != null )
+        if ( rootProject != null )
         {
 
             TaskSegment currentSegment = null;
@@ -322,7 +446,7 @@
 
                 // if it's a phase, then we don't need to check whether it's an aggregator.
                 // simply add it to the current task partition.
-                if ( getPhaseToLifecycleMap().containsKey( task ) )
+                if ( LifecycleUtils.isValidPhaseName( task ) )
                 {
                     if ( currentSegment != null && currentSegment.aggregate() )
                     {
@@ -340,18 +464,33 @@
                 else
                 {
                     MojoDescriptor mojo = null;
+                    // definitely a CLI goal, can use prefix
                     try
                     {
-                        // definitely a CLI goal, can use prefix
-                        mojo = getMojoDescriptor( task, session, project, task, true, false );
+                        mojo = getMojoDescriptorForDirectInvocation( task, session, rootProject );
                     }
-                    catch ( PluginNotFoundException e )
+                    catch ( PluginLoaderException e )
                     {
-                        // TODO: shouldn't hit this, investigate using the same resolution logic as otheres for plugins in the reactor
+                        // TODO: shouldn't hit this, investigate using the same resolution logic as 
+                        // others for plugins in the reactor
                         getLogger().info(
                             "Cannot find mojo descriptor for: \'" + task + "\' - Treating as non-aggregator." );
+                        
                         getLogger().debug( "", e );
                     }
+                    catch ( LifecycleSpecificationException e )
+                    {
+                        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 BuildFailureException( message, e );
+                    }
+                    catch ( LifecycleLoaderException e )
+                    {
+                        String message = "Cannot find plugin to match task '" + task + "'.";
+                    
+                        throw new BuildFailureException( message, e );
+                    }
 
                     // if the mojo descriptor was found, determine aggregator status according to:
                     // 1. whether the mojo declares itself an aggregator
@@ -404,870 +543,77 @@
         return segments;
     }
 
-    private void executeGoal( String task, MavenSession session, MavenProject project )
-        throws LifecycleExecutionException, BuildFailureException
-    {
-        try
-        {
-            Stack forkEntryPoints = new Stack();
-            if ( getPhaseToLifecycleMap().containsKey( task ) )
-            {
-                Lifecycle lifecycle = getLifecycleForPhase( task );
-
-                // we have a lifecycle phase, so lets bind all the necessary goals
-                Map lifecycleMappings = constructLifecycleMappings( session, task, project, lifecycle );
-                executeGoalWithLifecycle( task, forkEntryPoints, session, lifecycleMappings, project, lifecycle );
-            }
-            else
-            {
-                executeStandaloneGoal( task, forkEntryPoints, session, project );
-            }
-        }
-        catch ( PluginNotFoundException e )
-        {
-            throw new BuildFailureException( "A required plugin was not found: " + e.getMessage(), e );
-        }
-    }
-
-    private void executeGoalWithLifecycle( String task, Stack forkEntryPoints, MavenSession session,
-                                           Map lifecycleMappings, MavenProject project, Lifecycle lifecycle )
-        throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
-    {
-        List goals = processGoalChain( task, lifecycleMappings, lifecycle );
-
-        if ( !goals.isEmpty() )
-        {
-            executeGoals( goals, forkEntryPoints, session, project );
-        }
-        else
-        {
-            getLogger().info( "No goals needed for project - skipping" );
-        }
-    }
-
-    private void executeStandaloneGoal( String task, Stack forkEntryPoints, MavenSession session, MavenProject project )
-        throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
-    {
-        // guaranteed to come from the CLI and not be part of a phase
-        MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session, project, task, true, false );
-        executeGoals( Collections.singletonList( new MojoExecution( mojoDescriptor ) ), forkEntryPoints, session,
-                      project );
-    }
-
-    private void executeGoals( List goals, Stack forkEntryPoints, MavenSession session, MavenProject project )
-        throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
+    /**
+     * @todo Not particularly happy about this. Would like WagonManager and ArtifactTypeHandlerManager to be able to
+     * lookup directly, or have them passed in
+     * 
+     * @todo Move this sort of thing to the tail end of the project-building process
+     */
+    private Map findArtifactTypeHandlers( MavenSession session )
+        throws LifecycleExecutionException, PluginNotFoundException
     {
-        for ( Iterator i = goals.iterator(); i.hasNext(); )
+        Map map = new HashMap();
+        for ( Iterator projectIterator = session.getSortedProjects().iterator(); projectIterator.hasNext(); )
         {
-            MojoExecution mojoExecution = (MojoExecution) i.next();
-
-            MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
-
-            if ( mojoDescriptor.getExecutePhase() != null || mojoDescriptor.getExecuteGoal() != null )
-            {
-                forkEntryPoints.push( mojoDescriptor );
-
-                forkLifecycle( mojoDescriptor, forkEntryPoints, session, project );
-
-                forkEntryPoints.pop();
-            }
-
-            if ( mojoDescriptor.isRequiresReports() )
+            MavenProject project = (MavenProject) projectIterator.next();
+            
+            for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
             {
-                List reports = getReports( project, mojoExecution, session );
-
-                mojoExecution.setReports( reports );
+                Plugin plugin = (Plugin) i.next();
 
-                for ( Iterator j = mojoExecution.getForkedExecutions().iterator(); j.hasNext(); )
+                if ( plugin.isExtensions() )
                 {
-                    MojoExecution forkedExecution = (MojoExecution) j.next();
-                    MojoDescriptor descriptor = forkedExecution.getMojoDescriptor();
+                    verifyPlugin( plugin, project, session );
 
-                    if ( descriptor.getExecutePhase() != null )
+                    // TODO: if moved to the plugin manager we already have the descriptor from above and so do can lookup the container directly
+                    try
                     {
-                        forkEntryPoints.push( descriptor );
-
-                        forkLifecycle( descriptor, forkEntryPoints, session, project );
-
-                        forkEntryPoints.pop();
+                        Map components = pluginManager.getPluginComponents( plugin, ArtifactHandler.ROLE );
+                        map.putAll( components );
                     }
-                }
-            }
-
-            try
-            {
-                pluginManager.executeMojo( project, mojoExecution, session );
-            }
-            catch ( PluginManagerException e )
-            {
-                throw new LifecycleExecutionException( "Internal error in the plugin manager executing goal '" +
-                    mojoDescriptor.getId() + "': " + e.getMessage(), e );
-            }
-            catch ( ArtifactNotFoundException e )
-            {
-                throw new LifecycleExecutionException( e.getMessage(), e );
-            }
-            catch ( InvalidDependencyVersionException e )
-            {
-                throw new LifecycleExecutionException( e.getMessage(), e );
-            }
-            catch ( ArtifactResolutionException e )
-            {
-                throw new LifecycleExecutionException( e.getMessage(), e );
-            }
-            catch ( MojoFailureException e )
-            {
-                throw new BuildFailureException( e.getMessage(), e );
-            }
-            catch ( MojoExecutionException e )
-            {
-                throw new LifecycleExecutionException( e.getMessage(), e );
-            }
-            catch ( PluginConfigurationException e )
-            {
-                throw new LifecycleExecutionException( e.getMessage(), e );
-            }
-        }
-    }
-
-    private List getReports( MavenProject project, MojoExecution mojoExecution, MavenSession session )
-        throws LifecycleExecutionException, PluginNotFoundException
-    {
-        List reportPlugins = project.getReportPlugins();
-
-        if ( project.getModel().getReports() != null )
-        {
-            getLogger().error(
-                "Plugin contains a <reports/> section: this is IGNORED - please use <reporting/> instead." );
-        }
-
-        if ( project.getReporting() == null || !project.getReporting().isExcludeDefaults() )
-        {
-            if ( reportPlugins == null )
-            {
-                reportPlugins = new ArrayList();
-            }
-            else
-            {
-                reportPlugins = new ArrayList( reportPlugins );
-            }
-
-            for ( Iterator i = defaultReports.iterator(); i.hasNext(); )
-            {
-                String report = (String) i.next();
-
-                StringTokenizer tok = new StringTokenizer( report, ":" );
-                if ( tok.countTokens() != 2 )
-                {
-                    getLogger().warn( "Invalid default report ignored: '" + report + "' (must be groupId:artifactId)" );
-                }
-                else
-                {
-                    String groupId = tok.nextToken();
-                    String artifactId = tok.nextToken();
-
-                    boolean found = false;
-                    for ( Iterator j = reportPlugins.iterator(); j.hasNext() && !found; )
+                    catch ( ComponentLookupException e )
                     {
-                        ReportPlugin reportPlugin = (ReportPlugin) j.next();
-                        if ( reportPlugin.getGroupId().equals( groupId ) &&
-                            reportPlugin.getArtifactId().equals( artifactId ) )
-                        {
-                            found = true;
-                        }
+                        getLogger().debug( "Unable to find the lifecycle component in the extension", e );
                     }
-
-                    if ( !found )
+                    catch ( PluginManagerException e )
                     {
-                        ReportPlugin reportPlugin = new ReportPlugin();
-                        reportPlugin.setGroupId( groupId );
-                        reportPlugin.setArtifactId( artifactId );
-                        reportPlugins.add( reportPlugin );
+                        throw new LifecycleExecutionException( "Error looking up available components from plugin '" +
+                            plugin.getKey() + "': " + e.getMessage(), e );
                     }
-                }
-            }
-        }
-
-        List reports = new ArrayList();
-        if ( reportPlugins != null )
-        {
-            for ( Iterator it = reportPlugins.iterator(); it.hasNext(); )
-            {
-                ReportPlugin reportPlugin = (ReportPlugin) it.next();
 
-                List reportSets = reportPlugin.getReportSets();
-
-                if ( reportSets == null || reportSets.isEmpty() )
-                {
-                    reports.addAll( getReports( reportPlugin, null, project, session, mojoExecution ) );
-                }
-                else
-                {
-                    for ( Iterator j = reportSets.iterator(); j.hasNext(); )
+                    // shudder...
+                    for ( Iterator j = map.values().iterator(); j.hasNext(); )
                     {
-                        ReportSet reportSet = (ReportSet) j.next();
-
-                        reports.addAll( getReports( reportPlugin, reportSet, project, session, mojoExecution ) );
+                        ArtifactHandler handler = (ArtifactHandler) j.next();
+                        if ( project.getPackaging().equals( handler.getPackaging() ) )
+                        {
+                            project.getArtifact().setArtifactHandler( handler );
+                        }
                     }
                 }
             }
         }
-        return reports;
+        return map;
     }
 
-    private List getReports( ReportPlugin reportPlugin, ReportSet reportSet, MavenProject project, MavenSession session,
-                             MojoExecution mojoExecution )
+    private PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, MavenSession session )
         throws LifecycleExecutionException, PluginNotFoundException
     {
-        PluginDescriptor pluginDescriptor = verifyReportPlugin( reportPlugin, project, session );
-
-        List reports = new ArrayList();
-        for ( Iterator i = pluginDescriptor.getMojos().iterator(); i.hasNext(); )
+        getLogger().debug( "Verifying plugin: " + plugin.getKey() );
+        
+        PluginDescriptor pluginDescriptor;
+        try
         {
-            MojoDescriptor mojoDescriptor = (MojoDescriptor) i.next();
-
-            // TODO: check ID is correct for reports
-            // if the POM configured no reports, give all from plugin
-            if ( reportSet == null || reportSet.getReports().contains( mojoDescriptor.getGoal() ) )
-            {
-                String id = null;
-                if ( reportSet != null )
-                {
-                    id = reportSet.getId();
-                }
-
-                MojoExecution reportExecution = new MojoExecution( mojoDescriptor, id );
-
-                try
-                {
-                    MavenReport reportMojo = pluginManager.getReport( project, reportExecution, session );
-
-                    // Comes back null if it was a plugin, not a report - these are mojos in the reporting plugins that are not reports
-                    if ( reportMojo != null )
-                    {
-                        reports.add( reportMojo );
-                        mojoExecution.addMojoExecution( reportExecution );
-                    }
-                }
-                catch ( PluginManagerException e )
-                {
-                    throw new LifecycleExecutionException(
-                        "Error getting reports from the plugin '" + reportPlugin.getKey() + "': " + e.getMessage(), e );
-                }
-                catch ( PluginConfigurationException e )
-                {
-                    throw new LifecycleExecutionException(
-                        "Error getting reports from the plugin '" + reportPlugin.getKey() + "'", e );
-                }
-                catch ( ArtifactNotFoundException e )
-                {
-                    throw new LifecycleExecutionException( e.getMessage(), e );
-                }
-                catch ( ArtifactResolutionException e )
-                {
-                    throw new LifecycleExecutionException( e.getMessage(), e );
-                }
-            }
+            pluginDescriptor = pluginManager.verifyPlugin( plugin, project, session );
         }
-        return reports;
-    }
-
-    private void forkLifecycle( MojoDescriptor mojoDescriptor, Stack ancestorLifecycleForkers, MavenSession session,
-                                MavenProject project )
-        throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
-    {
-        PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
-        getLogger().info( "Preparing " + pluginDescriptor.getGoalPrefix() + ":" + mojoDescriptor.getGoal() );
-
-        if ( mojoDescriptor.isAggregator() )
+        catch ( PluginManagerException e )
         {
-            for ( Iterator i = session.getSortedProjects().iterator(); i.hasNext(); )
-            {
-                MavenProject reactorProject = (MavenProject) i.next();
-
-                line();
-
-                getLogger().info( "Building " + reactorProject.getName() );
-
-                line();
-
-                forkProjectLifecycle( mojoDescriptor, ancestorLifecycleForkers, session, reactorProject );
-            }
+            throw new LifecycleExecutionException(
+                "Internal error in the plugin manager getting plugin '" + plugin.getKey() + "': " + e.getMessage(), e );
         }
-        else
+        catch ( PluginVersionResolutionException e )
         {
-            forkProjectLifecycle( mojoDescriptor, ancestorLifecycleForkers, session, project );
-        }
-    }
-
-    private void forkProjectLifecycle( MojoDescriptor mojoDescriptor, Stack forkEntryPoints, MavenSession session,
-                                       MavenProject project )
-        throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
-    {
-        forkEntryPoints.push( mojoDescriptor );
-
-        PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
-
-        String targetPhase = mojoDescriptor.getExecutePhase();
-
-        Map lifecycleMappings = null;
-        if ( targetPhase != null )
-        {
-            Lifecycle lifecycle = getLifecycleForPhase( targetPhase );
-
-            // Create new lifecycle
-            lifecycleMappings = constructLifecycleMappings( session, targetPhase, project, lifecycle );
-
-            String executeLifecycle = mojoDescriptor.getExecuteLifecycle();
-            if ( executeLifecycle != null )
-            {
-                org.apache.maven.plugin.lifecycle.Lifecycle lifecycleOverlay;
-                try
-                {
-                    lifecycleOverlay = pluginDescriptor.getLifecycleMapping( executeLifecycle );
-                }
-                catch ( IOException e )
-                {
-                    throw new LifecycleExecutionException( "Unable to read lifecycle mapping file: " + e.getMessage(),
-                                                           e );
-                }
-                catch ( XmlPullParserException e )
-                {
-                    throw new LifecycleExecutionException( "Unable to parse lifecycle mapping file: " + e.getMessage(),
-                                                           e );
-                }
-
-                if ( lifecycleOverlay == null )
-                {
-                    throw new LifecycleExecutionException( "Lifecycle '" + executeLifecycle + "' not found in plugin" );
-                }
-
-                for ( Iterator i = lifecycleOverlay.getPhases().iterator(); i.hasNext(); )
-                {
-                    Phase phase = (Phase) i.next();
-                    for ( Iterator j = phase.getExecutions().iterator(); j.hasNext(); )
-                    {
-                        Execution exec = (Execution) j.next();
-
-                        for ( Iterator k = exec.getGoals().iterator(); k.hasNext(); )
-                        {
-                            String goal = (String) k.next();
-
-                            PluginDescriptor lifecyclePluginDescriptor;
-                            String lifecycleGoal;
-
-                            // Here we are looking to see if we have a mojo from an external plugin.
-                            // If we do then we need to lookup the plugin descriptor for the externally
-                            // referenced plugin so that we can overly the execution into the lifecycle.
-                            // An example of this is the corbertura plugin that needs to call the surefire
-                            // plugin in forking mode.
-                            //
-                            //<phase>
-                            //  <id>test</id>
-                            //  <executions>
-                            //    <execution>
-                            //      <goals>
-                            //        <goal>org.apache.maven.plugins:maven-surefire-plugin:test</goal>
-                            //      </goals>
-                            //      <configuration>
-                            //        <classesDirectory>${project.build.directory}/generated-classes/cobertura</classesDirectory>
-                            //        <ignoreFailures>true</ignoreFailures>
-                            //        <forkMode>once</forkMode>
-                            //      </configuration>
-                            //    </execution>
-                            //  </executions>
-                            //</phase>
-
-                            // ----------------------------------------------------------------------
-                            //
-                            // ----------------------------------------------------------------------
-
-                            if ( goal.indexOf( ":" ) > 0 )
-                            {
-                                String[] s = StringUtils.split( goal, ":" );
-
-                                String groupId = s[0];
-                                String artifactId = s[1];
-                                lifecycleGoal = s[2];
-
-                                Plugin plugin = new Plugin();
-                                plugin.setGroupId( groupId );
-                                plugin.setArtifactId( artifactId );
-                                lifecyclePluginDescriptor = verifyPlugin( plugin, project, session );
-                                if ( lifecyclePluginDescriptor == null )
-                                {
-                                    throw new LifecycleExecutionException(
-                                        "Unable to find plugin " + groupId + ":" + artifactId );
-                                }
-                            }
-                            else
-                            {
-                                lifecyclePluginDescriptor = pluginDescriptor;
-                                lifecycleGoal = goal;
-                            }
-
-                            Xpp3Dom configuration = (Xpp3Dom) exec.getConfiguration();
-                            if ( phase.getConfiguration() != null )
-                            {
-                                configuration = Xpp3Dom.mergeXpp3Dom( new Xpp3Dom( (Xpp3Dom) phase.getConfiguration() ),
-                                                                      configuration );
-                            }
-
-                            MojoDescriptor desc = getMojoDescriptor( lifecyclePluginDescriptor, lifecycleGoal );
-                            MojoExecution mojoExecution = new MojoExecution( desc, configuration );
-                            addToLifecycleMappings( lifecycleMappings, phase.getId(), mojoExecution,
-                                                    session.getSettings() );
-                        }
-                    }
-
-                    if ( phase.getConfiguration() != null )
-                    {
-                        // Merge in general configuration for a phase.
-                        // TODO: this is all kind of backwards from the POMM. Let's align it all under 2.1.
-                        //   We should create a new lifecycle executor for modelVersion >5.0.0
-                        for ( Iterator j = lifecycleMappings.values().iterator(); j.hasNext(); )
-                        {
-                            List tasks = (List) j.next();
-
-                            for ( Iterator k = tasks.iterator(); k.hasNext(); )
-                            {
-                                MojoExecution exec = (MojoExecution) k.next();
-
-                                Xpp3Dom configuration = Xpp3Dom.mergeXpp3Dom(
-                                    new Xpp3Dom( (Xpp3Dom) phase.getConfiguration() ), exec.getConfiguration() );
-
-                                exec.setConfiguration( configuration );
-                            }
-                        }
-                    }
-
-                }
-            }
-
-            removeFromLifecycle( forkEntryPoints, lifecycleMappings );
-        }
-
-        MavenProject executionProject = new MavenProject( project );
-        if ( targetPhase != null )
-        {
-            Lifecycle lifecycle = getLifecycleForPhase( targetPhase );
-
-            executeGoalWithLifecycle( targetPhase, forkEntryPoints, session, lifecycleMappings, executionProject,
-                                      lifecycle );
-        }
-        else
-        {
-            String goal = mojoDescriptor.getExecuteGoal();
-            MojoDescriptor desc = getMojoDescriptor( pluginDescriptor, goal );
-            executeGoals( Collections.singletonList( new MojoExecution( desc ) ), forkEntryPoints, session,
-                          executionProject );
-        }
-        project.setExecutionProject( executionProject );
-    }
-
-    private Lifecycle getLifecycleForPhase( String phase )
-        throws BuildFailureException, LifecycleExecutionException
-    {
-        Lifecycle lifecycle = (Lifecycle) getPhaseToLifecycleMap().get( phase );
-
-        if ( lifecycle == null )
-        {
-            throw new BuildFailureException( "Unable to find lifecycle for phase '" + phase + "'" );
-        }
-        return lifecycle;
-    }
-
-    private MojoDescriptor getMojoDescriptor( PluginDescriptor pluginDescriptor, String goal )
-        throws LifecycleExecutionException
-    {
-        MojoDescriptor desc = pluginDescriptor.getMojo( goal );
-
-        if ( desc == null )
-        {
-            String message =
-                "Required goal '" + goal + "' not found in plugin '" + pluginDescriptor.getGoalPrefix() + "'";
-            int index = goal.indexOf( ':' );
-            if ( index >= 0 )
-            {
-                String prefix = goal.substring( index + 1 );
-                if ( prefix.equals( pluginDescriptor.getGoalPrefix() ) )
-                {
-                    message = message + " (goals should not be prefixed - try '" + prefix + "')";
-                }
-            }
-            throw new LifecycleExecutionException( message );
-        }
-        return desc;
-    }
-
-    private void removeFromLifecycle( Stack lifecycleForkers, Map lifecycleMappings )
-    {
-        for ( Iterator it = lifecycleForkers.iterator(); it.hasNext(); )
-        {
-            MojoDescriptor mojoDescriptor = (MojoDescriptor) it.next();
-
-            for ( Iterator lifecycleIterator = lifecycleMappings.values().iterator(); lifecycleIterator.hasNext(); )
-            {
-                List tasks = (List) lifecycleIterator.next();
-
-                boolean removed = false;
-                for ( Iterator taskIterator = tasks.iterator(); taskIterator.hasNext(); )
-                {
-                    MojoExecution execution = (MojoExecution) taskIterator.next();
-
-                    if ( mojoDescriptor.equals( execution.getMojoDescriptor() ) )
-                    {
-                        taskIterator.remove();
-                        removed = true;
-                    }
-                }
-
-                if ( removed )
-                {
-                    getLogger().warn( "Removing: " + mojoDescriptor.getGoal() +
-                        " from forked lifecycle, to prevent recursive invocation." );
-                }
-            }
-        }
-    }
-
-    private Map constructLifecycleMappings( MavenSession session, String selectedPhase, MavenProject project,
-                                            Lifecycle lifecycle )
-        throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
-    {
-        // first, bind those associated with the packaging
-        Map lifecycleMappings = bindLifecycleForPackaging( session, selectedPhase, project, lifecycle );
-
-        // next, loop over plugins and for any that have a phase, bind it
-        for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
-        {
-            Plugin plugin = (Plugin) i.next();
-
-            bindPluginToLifecycle( plugin, session, lifecycleMappings, project );
-        }
-
-        return lifecycleMappings;
-    }
-
-    private Map bindLifecycleForPackaging( MavenSession session, String selectedPhase, MavenProject project,
-                                           Lifecycle lifecycle )
-        throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
-    {
-        Map mappings = findMappingsForLifecycle( session, project, lifecycle );
-
-        List optionalMojos = findOptionalMojosForLifecycle( session, project, lifecycle );
-
-        Map lifecycleMappings = new HashMap();
-
-        for ( Iterator i = lifecycle.getPhases().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 goal = tok.nextToken().trim();
-
-                    // Not from the CLI, don't use prefix
-                    MojoDescriptor mojoDescriptor = getMojoDescriptor( goal, session, project, selectedPhase, false,
-                                                                       optionalMojos.contains( goal ) );
-
-                    if ( mojoDescriptor == null )
-                    {
-                        continue;
-                    }
-
-                    if ( mojoDescriptor.isDirectInvocationOnly() )
-                    {
-                        throw new LifecycleExecutionException( "Mojo: \'" + goal +
-                            "\' requires direct invocation. It cannot be used as part of lifecycle: \'" +
-                            project.getPackaging() + "\'." );
-                    }
-
-                    addToLifecycleMappings( lifecycleMappings, phase, new MojoExecution( mojoDescriptor ),
-                                            session.getSettings() );
-                }
-            }
-
-            if ( phase.equals( selectedPhase ) )
-            {
-                break;
-            }
-        }
-
-        return lifecycleMappings;
-    }
-
-    private Map findMappingsForLifecycle( MavenSession session, MavenProject project, Lifecycle lifecycle )
-        throws LifecycleExecutionException, PluginNotFoundException
-    {
-        String packaging = project.getPackaging();
-        Map mappings = null;
-
-        LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, session );
-        if ( m != null )
-        {
-            mappings = m.getPhases( lifecycle.getId() );
-        }
-
-        Map defaultMappings = lifecycle.getDefaultPhases();
-
-        if ( mappings == null )
-        {
-            try
-            {
-                m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, packaging );
-                mappings = m.getPhases( lifecycle.getId() );
-            }
-            catch ( ComponentLookupException e )
-            {
-                if ( defaultMappings == null )
-                {
-                    throw new LifecycleExecutionException(
-                        "Cannot find lifecycle mapping for packaging: \'" + packaging + "\'.", e );
-                }
-            }
-        }
-
-        if ( mappings == null )
-        {
-            if ( defaultMappings == null )
-            {
-                throw new LifecycleExecutionException(
-                    "Cannot find lifecycle mapping for packaging: \'" + packaging + "\', and there is no default" );
-            }
-            else
-            {
-                mappings = defaultMappings;
-            }
-        }
-
-        return mappings;
-    }
-
-    private List findOptionalMojosForLifecycle( MavenSession session, MavenProject project, Lifecycle lifecycle )
-        throws LifecycleExecutionException, PluginNotFoundException
-    {
-        String packaging = project.getPackaging();
-        List optionalMojos = null;
-
-        LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, session );
-
-        if ( m != null )
-        {
-            optionalMojos = m.getOptionalMojos( lifecycle.getId() );
-        }
-
-        if ( optionalMojos == null )
-        {
-            try
-            {
-                m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, packaging );
-                optionalMojos = m.getOptionalMojos( lifecycle.getId() );
-            }
-            catch ( ComponentLookupException e )
-            {
-                getLogger().debug( "Error looking up lifecycle mapping to retrieve optional mojos. Lifecycle ID: " +
-                    lifecycle.getId() + ". Error: " + e.getMessage(), e );
-            }
-        }
-
-        if ( optionalMojos == null )
-        {
-            optionalMojos = Collections.EMPTY_LIST;
-        }
-
-        return optionalMojos;
-    }
-
-    private Object findExtension( MavenProject project, String role, String roleHint, MavenSession session )
-        throws LifecycleExecutionException, PluginNotFoundException
-    {
-        Object pluginComponent = null;
-
-        for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext() && pluginComponent == null; )
-        {
-            Plugin plugin = (Plugin) i.next();
-
-            if ( plugin.isExtensions() )
-            {
-                verifyPlugin( plugin, project, session );
-
-                // TODO: if moved to the plugin manager we already have the descriptor from above and so do can lookup the container directly
-                try
-                {
-                    pluginComponent = pluginManager.getPluginComponent( plugin, role, roleHint );
-                }
-                catch ( ComponentLookupException e )
-                {
-                    getLogger().debug( "Unable to find the lifecycle component in the extension", e );
-                }
-                catch ( PluginManagerException e )
-                {
-                    throw new LifecycleExecutionException(
-                        "Error getting extensions from the plugin '" + plugin.getKey() + "': " + e.getMessage(), e );
-                }
-            }
-        }
-        return pluginComponent;
-    }
-
-    /**
-     * @todo Not particularly happy about this. Would like WagonManager and ArtifactTypeHandlerManager to be able to
-     * lookup directly, or have them passed in
-     * 
-     * @todo Move this sort of thing to the tail end of the project-building process
-     */
-    private Map findArtifactTypeHandlers( MavenSession session )
-        throws LifecycleExecutionException, PluginNotFoundException
-    {
-        Map map = new HashMap();
-        for ( Iterator projectIterator = session.getSortedProjects().iterator(); projectIterator.hasNext(); )
-        {
-            MavenProject project = (MavenProject) projectIterator.next();
-            
-            for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
-            {
-                Plugin plugin = (Plugin) i.next();
-
-                if ( plugin.isExtensions() )
-                {
-                    verifyPlugin( plugin, project, session );
-
-                    // TODO: if moved to the plugin manager we already have the descriptor from above and so do can lookup the container directly
-                    try
-                    {
-                        Map components = pluginManager.getPluginComponents( plugin, ArtifactHandler.ROLE );
-                        map.putAll( components );
-                    }
-                    catch ( ComponentLookupException e )
-                    {
-                        getLogger().debug( "Unable to find the lifecycle component in the extension", e );
-                    }
-                    catch ( PluginManagerException e )
-                    {
-                        throw new LifecycleExecutionException( "Error looking up available components from plugin '" +
-                            plugin.getKey() + "': " + e.getMessage(), e );
-                    }
-
-                    // shudder...
-                    for ( Iterator j = map.values().iterator(); j.hasNext(); )
-                    {
-                        ArtifactHandler handler = (ArtifactHandler) j.next();
-                        if ( project.getPackaging().equals( handler.getPackaging() ) )
-                        {
-                            project.getArtifact().setArtifactHandler( handler );
-                        }
-                    }
-                }
-            }
-        }
-        return map;
-    }
-
-    /**
-     * Take each mojo contained with 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 that given phase.
-     *
-     * @param project
-     * @param session
-     */
-    private void bindPluginToLifecycle( Plugin plugin, MavenSession session, Map phaseMap, MavenProject project )
-        throws LifecycleExecutionException, PluginNotFoundException
-    {
-        Settings settings = session.getSettings();
-
-        PluginDescriptor pluginDescriptor =
-            verifyPlugin( plugin, project, 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() )
-            {
-                if ( plugin.getGoals() != null )
-                {
-                    getLogger().error(
-                        "Plugin contains a <goals/> section: this is IGNORED - please use <executions/> instead." );
-                }
-
-                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, MavenProject project, MavenSession session )
-        throws LifecycleExecutionException, PluginNotFoundException
-    {
-        getLogger().debug( "Verifying plugin: " + plugin.getKey() );
-        
-        PluginDescriptor pluginDescriptor;
-        try
-        {
-            pluginDescriptor = pluginManager.verifyPlugin( plugin, project, session );
-        }
-        catch ( PluginManagerException e )
-        {
-            throw new LifecycleExecutionException(
-                "Internal error in the plugin manager getting plugin '" + plugin.getKey() + "': " + e.getMessage(), e );
-        }
-        catch ( PluginVersionResolutionException e )
-        {
-            throw new LifecycleExecutionException( e.getMessage(), e );
-        }
-        catch ( InvalidVersionSpecificationException e )
-        {
-            throw new LifecycleExecutionException( e.getMessage(), e );
-        }
-        catch ( InvalidPluginException e )
-        {
-            throw new LifecycleExecutionException( e.getMessage(), e );
-        }
-        catch ( ArtifactNotFoundException e )
-        {
-            throw new LifecycleExecutionException( e.getMessage(), e );
-        }
-        catch ( ArtifactResolutionException e )
-        {
-            throw new LifecycleExecutionException( e.getMessage(), e );
-        }
-        catch ( PluginVersionNotFoundException e )
-        {
-            throw new LifecycleExecutionException( e.getMessage(), e );
-        }
-        return pluginDescriptor;
-    }
-
-    private PluginDescriptor verifyReportPlugin( ReportPlugin plugin, MavenProject project, MavenSession session )
-        throws LifecycleExecutionException, PluginNotFoundException
-    {
-        PluginDescriptor pluginDescriptor;
-        try
-        {
-            pluginDescriptor = pluginManager.verifyReportPlugin( plugin, project, session );
-        }
-        catch ( PluginManagerException e )
-        {
-            throw new LifecycleExecutionException(
-                "Internal error in the plugin manager getting report '" + plugin.getKey() + "': " + e.getMessage(), e );
-        }
-        catch ( PluginVersionResolutionException e )
-        {
-            throw new LifecycleExecutionException( e.getMessage(), e );
+            throw new LifecycleExecutionException( e.getMessage(), e );
         }
         catch ( InvalidVersionSpecificationException e )
         {
@@ -1292,270 +638,20 @@
         return pluginDescriptor;
     }
 
-    private void bindExecutionToLifecycle( PluginDescriptor pluginDescriptor, Map phaseMap, PluginExecution execution,
-                                           Settings settings )
-        throws LifecycleExecutionException
-    {
-        for ( Iterator i = execution.getGoals().iterator(); i.hasNext(); )
-        {
-            String goal = (String) i.next();
-
-            MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
-            if ( mojoDescriptor == null )
-            {
-                throw new LifecycleExecutionException(
-                    "Goal '" + goal + "' was specified in an execution, but not found in plugin " + pluginDescriptor.getId() );
-            }
-
-            // 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() );
-
-                String phase = execution.getPhase();
-
-                if ( phase == null )
-                {
-                    // if the phase was not in the configuration, use the phase in the descriptor
-                    phase = mojoDescriptor.getPhase();
-                }
-
-                if ( phase != null )
-                {
-                    if ( mojoDescriptor.isDirectInvocationOnly() )
-                    {
-                        throw new LifecycleExecutionException( "Mojo: \'" + goal +
-                            "\' requires direct invocation. It cannot be used as part of the lifecycle (it was included via the POM)." );
-                    }
-
-                    addToLifecycleMappings( phaseMap, phase, mojoExecution, settings );
-                }
-            }
-        }
-    }
-
-    private void addToLifecycleMappings( Map lifecycleMappings, String phase, MojoExecution mojoExecution,
-                                         Settings settings )
-    {
-        List goals = (List) lifecycleMappings.get( phase );
-
-        if ( goals == null )
-        {
-            goals = new ArrayList();
-            lifecycleMappings.put( phase, goals );
-        }
-
-        MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
-        if ( settings.isOffline() && mojoDescriptor.isOnlineRequired() )
-        {
-            String goal = mojoDescriptor.getGoal();
-            getLogger().warn( goal + " requires online mode, but maven is currently offline. Disabling " + goal + "." );
-        }
-        else
-        {
-            goals.add( mojoExecution );
-        }
-    }
-
-    private List processGoalChain( String task, Map phaseMap, Lifecycle lifecycle )
-    {
-        List goals = new ArrayList();
-
-        // only execute up to the given phase
-        int index = lifecycle.getPhases().indexOf( task );
-
-        for ( int i = 0; i <= index; i++ )
-        {
-            String p = (String) lifecycle.getPhases().get( i );
-
-            List phaseGoals = (List) phaseMap.get( p );
-
-            if ( phaseGoals != null )
-            {
-                goals.addAll( phaseGoals );
-            }
-        }
-        return goals;
-    }
-
-    private MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProject project,
-                                              String invokedVia, boolean canUsePrefix, boolean isOptionalMojo )
-        throws BuildFailureException, LifecycleExecutionException, PluginNotFoundException
+    private MojoDescriptor getMojoDescriptorForDirectInvocation( String task, MavenSession session, MavenProject project )
+        throws LifecycleSpecificationException, PluginLoaderException, LifecycleLoaderException
     {
-        String goal;
-        Plugin plugin;
-
-        PluginDescriptor pluginDescriptor = null;
-
-        try
-        {
-            StringTokenizer tok = new StringTokenizer( task, ":" );
-            int numTokens = tok.countTokens();
-
-            if ( numTokens == 2 )
-            {
-                if ( !canUsePrefix )
-                {
-                    String msg = "Mapped-prefix lookup of mojos are only supported from direct invocation. " +
-                        "Please use specification of the form groupId:artifactId[:version]:goal instead. " +
-                        "(Offending mojo: \'" + task + "\', invoked via: \'" + invokedVia + "\')";
-                    throw new LifecycleExecutionException( msg );
-                }
-
-                String prefix = tok.nextToken();
-                goal = tok.nextToken();
-
-                // Steps for retrieving the plugin model instance:
-                // 1. request directly from the plugin collector by prefix
-                pluginDescriptor = pluginManager.getPluginDescriptorForPrefix( prefix );
-
-                // 2. look in the repository via search groups
-                if ( pluginDescriptor == null )
-                {
-                    plugin = pluginManager.getPluginDefinitionForPrefix( prefix, session, project );
-                }
-                else
-                {
-                    plugin = new Plugin();
-
-                    plugin.setGroupId( pluginDescriptor.getGroupId() );
-                    plugin.setArtifactId( pluginDescriptor.getArtifactId() );
-                    plugin.setVersion( pluginDescriptor.getVersion() );
-                }
-
-                // 3. search plugins in the current POM
-                if ( plugin == null )
-                {
-                    for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
-                    {
-                        Plugin buildPlugin = (Plugin) i.next();
-
-                        PluginDescriptor desc = verifyPlugin( buildPlugin, project, session );
-
-                        if ( prefix.equals( desc.getGoalPrefix() ) )
-                        {
-                            plugin = buildPlugin;
-                        }
-                    }
-                }
-
-                // 4. default to o.a.m.plugins and maven-<prefix>-plugin
-                if ( plugin == null )
-                {
-                    plugin = new Plugin();
-                    plugin.setGroupId( PluginDescriptor.getDefaultPluginGroupId() );
-                    plugin.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId( prefix ) );
-                }
-
-                for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
-                {
-                    Plugin buildPlugin = (Plugin) i.next();
-
-                    if ( buildPlugin.getKey().equals( plugin.getKey() ) )
-                    {
-                        plugin = buildPlugin;
-                        break;
-                    }
-                }
-            }
-            else if ( numTokens == 3 || numTokens == 4 )
-            {
-                plugin = new Plugin();
-
-                plugin.setGroupId( tok.nextToken() );
-                plugin.setArtifactId( tok.nextToken() );
-
-                if ( numTokens == 4 )
-                {
-                    plugin.setVersion( tok.nextToken() );
-                }
-
-                goal = tok.nextToken();
-            }
-            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";
-                throw new BuildFailureException( message );
-            }
-
-            project.injectPluginManagementInfo( plugin );
-
-            if ( pluginDescriptor == null )
-            {
-                pluginDescriptor = verifyPlugin( plugin, project, session );
-            }
-
-            // this has been simplified from the old code that injected the plugin management stuff, since
-            // pluginManagement injection is now handled by the project method.
-            project.addPlugin( plugin );
-
-            MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
-            if ( mojoDescriptor == null )
-            {
-                if ( isOptionalMojo )
-                {
-                    getLogger().info( "Skipping missing optional mojo: " + task );
-                }
-                else
-                {
-                    throw new BuildFailureException( "Required goal not found: " + task );
-                }
-            }
-
-            return mojoDescriptor;
-        }
-        catch ( PluginNotFoundException e )
-        {
-            if ( isOptionalMojo )
-            {
-                getLogger().info( "Skipping missing optional mojo: " + task );
-                getLogger().debug( "Mojo: " + task + " could not be found. Reason: " + e.getMessage(), e );
-            }
-            else
-            {
-                throw e;
-            }
-        }
-
-        return null;
+        MojoBinding binding = mojoBindingFactory.parseMojoBinding( task, project, true );
+        
+        PluginDescriptor descriptor = pluginLoader.loadPlugin( binding, project );
+        MojoDescriptor mojoDescriptor = descriptor.getMojo( binding.getGoal() );
+        
+        return mojoDescriptor;
     }
 
     protected void line()
     {
         getLogger().info( "----------------------------------------------------------------------------" );
-    }
-
-    public Map getPhaseToLifecycleMap()
-        throws LifecycleExecutionException
-    {
-        if ( phaseToLifecycleMap == null )
-        {
-            phaseToLifecycleMap = new HashMap();
-
-            for ( Iterator i = lifecycles.iterator(); i.hasNext(); )
-            {
-                Lifecycle lifecycle = (Lifecycle) i.next();
-
-                for ( Iterator p = lifecycle.getPhases().iterator(); p.hasNext(); )
-                {
-                    String phase = (String) p.next();
-
-                    if ( phaseToLifecycleMap.containsKey( phase ) )
-                    {
-                        Lifecycle prevLifecycle = (Lifecycle) phaseToLifecycleMap.get( phase );
-                        throw new LifecycleExecutionException( "Phase '" + phase +
-                            "' is defined in more than one lifecycle: '" + lifecycle.getId() + "' and '" +
-                            prevLifecycle.getId() + "'" );
-                    }
-                    else
-                    {
-                        phaseToLifecycleMap.put( phase, lifecycle );
-                    }
-                }
-            }
-        }
-        return phaseToLifecycleMap;
     }
 
     private static class TaskSegment

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.java?view=diff&rev=520609&r1=520608&r2=520609
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.java Tue Mar 20 14:40:59 2007
@@ -25,7 +25,7 @@
 import java.util.Map;
 
 /**
- * Lifecycle mapping for a POM.
+ * LegacyLifecycle mapping for a POM.
  *
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  * @version $Id$

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/Lifecycle.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/Lifecycle.java?view=diff&rev=520609&r1=520608&r2=520609
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/Lifecycle.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/Lifecycle.java Tue Mar 20 14:40:59 2007
@@ -24,7 +24,7 @@
 import java.util.Map;
 
 /**
- * Class Lifecycle.
+ * Class LegacyLifecycle.
  */
 public class Lifecycle
 {

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?view=diff&rev=520609&r1=520608&r2=520609
==============================================================================
--- 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 Tue Mar 20 14:40:59 2007
@@ -36,8 +36,11 @@
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
 import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.context.BuildContextManager;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.execution.RuntimeInformation;
+import org.apache.maven.lifecycle.LifecycleExecutionContext;
+import org.apache.maven.lifecycle.statemgmt.StateManagementUtils;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.ReportPlugin;
 import org.apache.maven.monitor.event.EventDispatcher;
@@ -92,6 +95,17 @@
     extends AbstractLogEnabled
     implements PluginManager, Contextualizable
 {
+    private static final List RESERVED_GROUP_IDS;
+    
+    static
+    {
+        List rgids = new ArrayList();
+        
+        rgids.add( StateManagementUtils.GROUP_ID );
+        
+        RESERVED_GROUP_IDS = rgids;
+    }
+
     protected PlexusContainer container;
 
     protected PluginDescriptorBuilder pluginDescriptorBuilder;
@@ -119,6 +133,8 @@
 
     protected PluginMappingManager pluginMappingManager;
 
+    private BuildContextManager buildContextManager;
+
     // END component requirements
 
     public DefaultPluginManager()
@@ -157,6 +173,7 @@
         // All version-resolution logic has been moved to DefaultPluginVersionManager.
         if ( plugin.getVersion() == null )
         {
+            getLogger().debug( "Resolving version for plugin: " + plugin.getKey() );
             String version = pluginVersionManager.resolvePluginVersion( plugin.getGroupId(), plugin.getArtifactId(),
                                                                         project, session );
             plugin.setVersion( version );
@@ -189,27 +206,38 @@
         // the 'Can't find plexus container for plugin: xxx' error.
         try
         {
-            VersionRange versionRange = VersionRange.createFromVersionSpec( plugin.getVersion() );
+            // if the groupId is internal, don't try to resolve it...
+            if ( !RESERVED_GROUP_IDS.contains( plugin.getGroupId() ) )
+            {
+                VersionRange versionRange = VersionRange.createFromVersionSpec( plugin.getVersion() );
 
-            List remoteRepositories = new ArrayList();
+                List remoteRepositories = new ArrayList();
 
-            remoteRepositories.addAll( project.getPluginArtifactRepositories() );
+                remoteRepositories.addAll( project.getPluginArtifactRepositories() );
 
-            remoteRepositories.addAll( project.getRemoteArtifactRepositories() );
+                remoteRepositories.addAll( project.getRemoteArtifactRepositories() );
 
-            checkRequiredMavenVersion( plugin, localRepository, remoteRepositories );
+                checkRequiredMavenVersion( plugin, localRepository, remoteRepositories );
 
-            Artifact pluginArtifact =
-                artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange );
+                Artifact pluginArtifact =
+                    artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange );
 
-            pluginArtifact = project.replaceWithActiveArtifact( pluginArtifact );
+                pluginArtifact = project.replaceWithActiveArtifact( pluginArtifact );
 
-            artifactResolver.resolve( pluginArtifact, project.getPluginArtifactRepositories(), localRepository );
+                artifactResolver.resolve( pluginArtifact, project.getPluginArtifactRepositories(), localRepository );
 
-//            if ( !pluginCollector.isPluginInstalled( plugin ) )
-//            {
-//            }
-            addPlugin( plugin, pluginArtifact, project, localRepository );
+//                if ( !pluginCollector.isPluginInstalled( plugin ) )
+//                {
+//                }
+                addPlugin( plugin, pluginArtifact, project, localRepository );
+            }
+            else
+            {
+                getLogger().debug( "Skipping resolution for Maven built-in plugin: " + plugin.getKey() );
+                
+                PluginDescriptor pd = pluginCollector.getPluginDescriptor( plugin );
+                pd.setClassRealm( container.getContainerRealm() );
+            }
 
             project.addPlugin( plugin );
         }
@@ -236,7 +264,9 @@
             }
         }
 
-        return pluginCollector.getPluginDescriptor( plugin );
+        PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( plugin );
+        
+        return pluginDescriptor;
     }
 
     /**
@@ -548,25 +578,13 @@
 
         PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
 
-        String goalId = mojoDescriptor.getGoal();
-
-        String groupId = pluginDescriptor.getGroupId();
-
-        String artifactId = pluginDescriptor.getArtifactId();
-
-        String executionId = mojoExecution.getExecutionId();
-
-        Xpp3Dom dom = project.getGoalConfiguration( groupId, artifactId, executionId, goalId );
-
-        Xpp3Dom reportDom = project.getReportConfiguration( groupId, artifactId, executionId );
-
-        dom = Xpp3Dom.mergeXpp3Dom( dom, reportDom );
-
-        if ( mojoExecution.getConfiguration() != null )
+        Xpp3Dom dom = (Xpp3Dom) mojoExecution.getConfiguration();
+        if ( dom != null )
         {
-            dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() );
+            // make a defensive copy, to keep things from getting polluted.
+            dom = new Xpp3Dom( dom );
         }
-
+        
         plugin = getConfiguredMojo( session, dom, project, false, mojoExecution );
 
         // Event monitoring.
@@ -596,7 +614,21 @@
             ClassRealm oldRealm = container.setLookupRealm( pluginRealm );
 
             plugin.execute();
-
+            
+            // NEW: If the mojo that just executed is a report, store it in the LifecycleExecutionContext
+            // for reference by future mojos.
+            if ( plugin instanceof MavenReport )
+            {
+                LifecycleExecutionContext ctx = LifecycleExecutionContext.read( buildContextManager );
+                if ( ctx == null )
+                {
+                    ctx = new LifecycleExecutionContext( project );
+                }
+                
+                ctx.addReport( mojoDescriptor, (MavenReport) plugin );
+                ctx.store( buildContextManager );
+            }
+            
             container.setLookupRealm( oldRealm );
 
             dispatcher.dispatchEnd( event, goalExecId );
@@ -757,7 +789,7 @@
         {
             pomConfiguration = new XmlPlexusConfiguration( dom );
         }
-
+        
         // Validate against non-editable (@readonly) parameters, to make sure users aren't trying to
         // override in the POM.
         validatePomConfiguration( mojoDescriptor, pomConfiguration );
@@ -768,9 +800,16 @@
         //            PlexusConfiguration mergedConfiguration = mergeConfiguration( pomConfiguration,
         //                                                                          mojoDescriptor.getConfiguration() );
 
-        ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution,
-                                                                                          pathTranslator, getLogger(),
-                                                                                          project,
+        // NEW: Pass in the LifecycleExecutionContext so we have access to the current project, 
+        // forked project stack (future), and reports.
+        LifecycleExecutionContext ctx = LifecycleExecutionContext.read( buildContextManager );
+        if ( ctx == null )
+        {
+            ctx = new LifecycleExecutionContext( project );
+        }
+        
+        ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution, pathTranslator,
+                                                                                          ctx, getLogger(),
                                                                                           session.getExecutionProperties() );
 
         PlexusConfiguration extractedMojoConfiguration =
@@ -1181,7 +1220,7 @@
     }
 
     // ----------------------------------------------------------------------
-    // Lifecycle
+    // LegacyLifecycle
     // ----------------------------------------------------------------------
 
     public void contextualize( Context context )

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java?view=diff&rev=520609&r1=520608&r2=520609
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java Tue Mar 20 14:40:59 2007
@@ -39,10 +39,6 @@
 
     private Xpp3Dom configuration;
 
-    private List forkedExecutions = new ArrayList();
-
-    private List reports;
-
     public MojoExecution( MojoDescriptor mojoDescriptor )
     {
         this.mojoDescriptor = mojoDescriptor;
@@ -77,26 +73,6 @@
     public Xpp3Dom getConfiguration()
     {
         return configuration;
-    }
-
-    public void addMojoExecution( MojoExecution execution )
-    {
-        forkedExecutions.add( execution );
-    }
-
-    public void setReports( List reports )
-    {
-        this.reports = reports;
-    }
-
-    public List getReports()
-    {
-        return reports;
-    }
-
-    public List getForkedExecutions()
-    {
-        return forkedExecutions;
     }
 
     public void setConfiguration( Xpp3Dom configuration )

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java?view=diff&rev=520609&r1=520608&r2=520609
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java Tue Mar 20 14:40:59 2007
@@ -20,6 +20,7 @@
  */
 
 import org.apache.maven.execution.MavenSession;
+import org.apache.maven.lifecycle.LifecycleExecutionContext;
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
 import org.apache.maven.project.MavenProject;
@@ -74,6 +75,49 @@
 
     private final Properties properties;
 
+    private final LifecycleExecutionContext lifecycleExecutionContext;
+
+    public PluginParameterExpressionEvaluator( MavenSession context,
+                                               MojoExecution mojoExecution,
+                                               PathTranslator pathTranslator,
+                                               LifecycleExecutionContext lifecycleExecutionContext,
+                                               Logger logger,
+                                               Properties properties )
+    {
+        this.context = context;
+        this.mojoExecution = mojoExecution;
+        this.pathTranslator = pathTranslator;
+        this.lifecycleExecutionContext = lifecycleExecutionContext;
+        this.logger = logger;
+        this.properties = properties;
+        
+        this.project = lifecycleExecutionContext.getCurrentProject();
+
+        String basedir = null;
+
+        if ( project != null )
+        {
+            File projectFile = project.getFile();
+
+            // this should always be the case for non-super POM instances...
+            if ( projectFile != null )
+            {
+                basedir = projectFile.getParentFile().getAbsolutePath();
+            }
+        }
+
+        if ( basedir == null )
+        {
+            basedir = System.getProperty( "user.dir" );
+        }
+
+        this.basedir = basedir;
+    }
+
+    /**
+     * @deprecated Use {@link PluginParameterExpressionEvaluator#PluginParameterExpressionEvaluator(MavenSession, MojoExecution, PathTranslator, LifecycleExecutionContext, Logger, Properties)}
+     * instead.
+     */
     public PluginParameterExpressionEvaluator( MavenSession context,
                                                MojoExecution mojoExecution,
                                                PathTranslator pathTranslator,
@@ -84,9 +128,11 @@
         this.context = context;
         this.mojoExecution = mojoExecution;
         this.pathTranslator = pathTranslator;
+        this.lifecycleExecutionContext = new LifecycleExecutionContext( project );
         this.logger = logger;
-        this.project = project;
         this.properties = properties;
+        
+        this.project = project;
 
         String basedir = null;
 
@@ -192,7 +238,7 @@
         }
         else if ( "reports".equals( expression ) )
         {
-            value = mojoExecution.getReports();
+            value = lifecycleExecutionContext.getReports();
         }
         else if ( "project".equals( expression ) )
         {

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java?view=diff&rev=520609&r1=520608&r2=520609
==============================================================================
--- 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 Tue Mar 20 14:40:59 2007
@@ -90,6 +90,7 @@
 
         // first pass...if the plugin is specified in the pom, try to retrieve the version from there.
         String version = getVersionFromPluginConfig( groupId, artifactId, project, resolveAsReportPlugin );
+        getLogger().debug( "Version from POM: " + version );
 
         // NOTE: We CANNOT check the current project version here, so delay it until later.
         // It will prevent plugins from building themselves, if they are part of the lifecycle mapping.
@@ -107,6 +108,7 @@
                 }
             }
         }
+        getLogger().debug( "Version from another POM in the reactor: " + version );
 
         // third pass...we're always checking for latest install/deploy, so retrieve the version for LATEST metadata and
         // also set that resolved version as the <useVersion/> in settings.xml.
@@ -114,6 +116,7 @@
         {
             // 1. resolve the version to be used
             version = resolveMetaVersion( groupId, artifactId, project, localRepository, Artifact.LATEST_VERSION );
+            getLogger().debug( "Version from LATEST metadata: " + version );
         }
 
         // final pass...retrieve the version for RELEASE and also set that resolved version as the <useVersion/>
@@ -122,6 +125,7 @@
         {
             // 1. resolve the version to be used
             version = resolveMetaVersion( groupId, artifactId, project, localRepository, Artifact.RELEASE_VERSION );
+            getLogger().debug( "Version from RELEASE metadata: " + version );
         }
 
         // if we're still empty here, and the current project matches the plugin in question, use the current project's
@@ -130,6 +134,7 @@
             project.getArtifactId().equals( artifactId ) )
         {
             version = project.getVersion();
+            getLogger().debug( "Version from POM itself (this project IS the plugin project): " + version );
         }
 
         // if we still haven't found a version, then fail early before we get into the update goop.