You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2010/04/14 23:23:26 UTC

svn commit: r934201 - in /maven/maven-3/trunk: maven-compat/src/test/java/org/apache/maven/project/ maven-core/src/main/java/org/apache/maven/lifecycle/ maven-core/src/main/java/org/apache/maven/lifecycle/internal/ maven-core/src/test/java/org/apache/m...

Author: krosenvold
Date: Wed Apr 14 21:23:26 2010
New Revision: 934201

URL: http://svn.apache.org/viewvc?rev=934201&view=rev
Log:
[MNG-4633] Fixed weave mode bug when building m3 itself in weave mode.

Updated testcase for MEP.

Also removed all unused/unecessar code from weave mode.

Modified:
    maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/MavenExecutionPlan.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ExecutionPlanItem.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleExecutionPlanCalculatorImpl.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleWeaveBuilder.java
    maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/MavenExecutionPlanTest.java
    maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/LifecycleWeaveBuilderTest.java
    maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/DefaultLifecyclesStub.java
    maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifecycleExecutionPlanCalculatorStub.java
    maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java

Modified: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java?rev=934201&r1=934200&r2=934201&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java (original)
+++ maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java Wed Apr 14 21:23:26 2010
@@ -52,7 +52,7 @@ public class EmptyLifecycleExecutor
         throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
         MojoNotFoundException
     {
-        return new MavenExecutionPlan(null, null, null );
+        return new MavenExecutionPlan(null, null, null, new DefaultLifecycles() );
     }
 
     public void execute( MavenSession session )

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java?rev=934201&r1=934200&r2=934201&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java Wed Apr 14 21:23:26 2010
@@ -14,15 +14,6 @@
  */
 package org.apache.maven.lifecycle;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.maven.lifecycle.internal.BuilderCommon;
 import org.apache.maven.lifecycle.internal.ExecutionPlanItem;
 import org.apache.maven.plugin.InvalidPluginDescriptorException;
@@ -37,6 +28,15 @@ import org.apache.maven.project.MavenPro
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.util.StringUtils;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 /**
  * @author Jason van Zyl
  * @author Kristian Rosenvold
@@ -49,10 +49,8 @@ public class DefaultLifecycles
 
     // @Configuration(source="org/apache/maven/lifecycle/lifecycles.xml")
 
-    // @Requirement(role=Lifecycle.class)
     private Map<String, Lifecycle> lifecycles;
 
-    // @Requirement
     private Logger logger;
 
     private List<Scheduling> schedules;
@@ -62,15 +60,12 @@ public class DefaultLifecycles
     {
     }
 
-    public DefaultLifecycles( List<Lifecycle> lifecycles, List<Scheduling> schedules )
+    public DefaultLifecycles( Map<String, Lifecycle> lifecycles, List<Scheduling> schedules, Logger logger )
     {
         this.lifecycles = new LinkedHashMap<String, Lifecycle>();
         this.schedules = schedules;
-
-        for ( Lifecycle lifecycle : lifecycles )
-        {
-            this.lifecycles.put( lifecycle.getId(), lifecycle );
-        }
+        this.logger = logger;
+        this.lifecycles = lifecycles;
     }
 
     public List<ExecutionPlanItem> createExecutionPlanItem( MavenProject mavenProject, List<MojoExecution> executions )
@@ -104,9 +99,9 @@ public class DefaultLifecycles
      * Gets scheduling associated with a given phase.
      * <p/>
      * This is part of the experimental weave mode and therefore not part of the public api.
-     * 
-     * @param lifecyclePhaseName
-     * @return
+     *
+     * @param lifecyclePhaseName The name of the lifecycle phase
+     * @return Schecduling information related to phase
      */
 
     private Scheduling getScheduling( String lifecyclePhaseName )
@@ -129,6 +124,8 @@ public class DefaultLifecycles
     /**
      * We use this to map all phases to the lifecycle that contains it. This is used so that a user can specify the
      * phase they want to execute and we can easily determine what lifecycle we need to run.
+     * 
+     * @return A map of lifecycles, indexed on id
      */
     public Map<String, Lifecycle> getPhaseToLifecycleMap()
     {
@@ -143,7 +140,7 @@ public class DefaultLifecycles
             {
                 logger.debug( "Lifecycle " + lifecycle );
             }
-            
+
             for ( String phase : lifecycle.getPhases() )
             {
                 // The first definition wins.
@@ -154,8 +151,9 @@ public class DefaultLifecycles
                 else
                 {
                     Lifecycle original = phaseToLifecycleMap.get( phase );
-                    logger.warn( "Duplicated lifecycle phase " + phase + ". Defined in " + original.getId()
-                        + " but also in " + lifecycle.getId() );
+                    logger.warn(
+                        "Duplicated lifecycle phase " + phase + ". Defined in " + original.getId() + " but also in " +
+                            lifecycle.getId() );
                 }
             }
         }

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/MavenExecutionPlan.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/MavenExecutionPlan.java?rev=934201&r1=934200&r2=934201&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/MavenExecutionPlan.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/MavenExecutionPlan.java Wed Apr 14 21:23:26 2010
@@ -19,6 +19,9 @@ package org.apache.maven.lifecycle;
  * under the License.
  */
 
+import org.apache.maven.lifecycle.internal.ExecutionPlanItem;
+import org.apache.maven.plugin.MojoExecution;
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -26,16 +29,13 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.maven.lifecycle.internal.ExecutionPlanItem;
-import org.apache.maven.plugin.MojoExecution;
-import org.apache.maven.plugin.descriptor.MojoDescriptor;
-
 //TODO: lifecycles being executed
 //TODO: what runs in each phase
 //TODO: plugins that need downloading
 //TODO: project dependencies that need downloading
 //TODO: unfortunately the plugins need to be downloaded in order to get the plugin.xml file. need to externalize this from the plugin archive.
 //TODO: this will be the class that people get in IDEs to modify
+
 public class MavenExecutionPlan
     implements Iterable<ExecutionPlanItem>
 {
@@ -48,44 +48,89 @@ public class MavenExecutionPlan
        separate this into a separate mutable structure.
 
      */
-    /** For project dependency resolution, the scopes of resolution required if any. */
+
+    /**
+     * For project dependency resolution, the scopes of resolution required if any.
+     */
     private final Set<String> requiredDependencyResolutionScopes;
 
-    /** For project dependency collection, the scopes of collection required if any. */
+    /**
+     * For project dependency collection, the scopes of collection required if any.
+     */
     private final Set<String> requiredDependencyCollectionScopes;
 
     private final List<ExecutionPlanItem> planItem;
 
-    private final Map<String, ExecutionPlanItem> lastInPhase;
-    private final List<String> phasesInOrder;
+    private final Map<String, ExecutionPlanItem> lastMojoExecutionForAllPhases;
+
+
+    final List<String> phases;
 
     public MavenExecutionPlan( Set<String> requiredDependencyResolutionScopes,
-                               Set<String> requiredDependencyCollectionScopes, List<ExecutionPlanItem> planItem )
+                               Set<String> requiredDependencyCollectionScopes, List<ExecutionPlanItem> planItem,
+                               DefaultLifecycles defaultLifecycles )
     {
         this.requiredDependencyResolutionScopes = requiredDependencyResolutionScopes;
         this.requiredDependencyCollectionScopes = requiredDependencyCollectionScopes;
         this.planItem = planItem;
-        lastInPhase = new HashMap<String, ExecutionPlanItem>();
-        phasesInOrder = new ArrayList<String>();
+        lastMojoExecutionForAllPhases = new HashMap<String, ExecutionPlanItem>();
+
+        String firstPhasePreset = getFirstPhasePresentInPlan();
+
+        List<String> phases = null;
+        if ( defaultLifecycles != null )
+        {
+            final Lifecycle lifecycle = defaultLifecycles.get( firstPhasePreset );
+            if ( lifecycle != null )
+            {
+                phases = lifecycle.getPhases();
+            }
+        }
+        this.phases = phases;
+
+        Map<String, ExecutionPlanItem> lastInExistingPhases = new HashMap<String, ExecutionPlanItem>();
         for ( ExecutionPlanItem executionPlanItem : getExecutionPlanItems() )
         {
-            final String phaseName = getPhase( executionPlanItem );
-            if ( !lastInPhase.containsKey( phaseName ) )
+            final String phaseName = executionPlanItem.getLifecyclePhase();
+            if ( phaseName != null )
+            {
+                lastInExistingPhases.put( phaseName, executionPlanItem );
+            }
+        }
+
+        ExecutionPlanItem lastSeenExecutionPlanItem = null;
+        ExecutionPlanItem forThis;
+
+        if ( phases != null )
+        {
+            for ( String phase : phases )
             {
-                phasesInOrder.add( phaseName );
+                forThis = lastInExistingPhases.get( phase );
+                if ( forThis != null )
+                {
+                    lastSeenExecutionPlanItem = forThis;
+                }
+                lastMojoExecutionForAllPhases.put( phase, lastSeenExecutionPlanItem );
+
             }
-            lastInPhase.put( phaseName, executionPlanItem );
         }
+
     }
 
-    private String getPhase( ExecutionPlanItem executionPlanItem )
+    private String getFirstPhasePresentInPlan()
     {
-        final MojoExecution mojoExecution = executionPlanItem.getMojoExecution();
-        final MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
-        return mojoDescriptor.getPhase();
-
+        for ( ExecutionPlanItem executionPlanItem : getExecutionPlanItems() )
+        {
+            final String phase = executionPlanItem.getLifecyclePhase();
+            if ( phase != null )
+            {
+                return phase;
+            }
+        }
+        return null;
     }
 
+
     public Iterator<ExecutionPlanItem> iterator()
     {
         return getExecutionPlanItems().iterator();
@@ -93,14 +138,23 @@ public class MavenExecutionPlan
 
     /**
      * Returns the last ExecutionPlanItem in the supplied phase. If no items are in the specified phase,
-     * the closest upstream item will be returned.
-     * @param executionPlanItem The execution plan item
+     * the closest executionPlanItem from an earlier phase item will be returned.
+     *
+     * @param requestedPhase the requested phase
+     *                       The execution plan item
      * @return The ExecutionPlanItem or null if none can be found
      */
-    public ExecutionPlanItem findLastInPhase( ExecutionPlanItem executionPlanItem )
+    public ExecutionPlanItem findLastInPhase( String requestedPhase )
     {
-        ExecutionPlanItem executionPlanItem1 = lastInPhase.get( getPhase( executionPlanItem ) );
-        return executionPlanItem1;
+        ExecutionPlanItem result = lastMojoExecutionForAllPhases.get( requestedPhase );
+        int i = phases.indexOf( requestedPhase );
+        while ( result == null && i > 0 )
+        {
+            final String previousPhase = phases.get( --i );
+            result = lastMojoExecutionForAllPhases.get( previousPhase );
+
+        }
+        return result;
     }
 
     private List<ExecutionPlanItem> getExecutionPlanItems()
@@ -136,6 +190,8 @@ public class MavenExecutionPlan
         return result;
     }
 
+    // Used by m2e but will be removed, really. 
+    @SuppressWarnings({"UnusedDeclaration"})
     @Deprecated
     public List<MojoExecution> getExecutions()
     {

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ExecutionPlanItem.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ExecutionPlanItem.java?rev=934201&r1=934200&r2=934201&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ExecutionPlanItem.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ExecutionPlanItem.java Wed Apr 14 21:23:26 2010
@@ -50,6 +50,16 @@ public class ExecutionPlanItem
         return mojoExecution;
     }
 
+    public String getLifecyclePhase()
+    {
+        final MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
+        if ( mojoDescriptor.getPhase() != null )
+        {
+            return mojoDescriptor.getPhase();
+        }
+        return mojoExecution.getLifecyclePhase();
+    }
+
     public void setComplete()
     {
         boolean transitionSuccessful = ensureComplete();

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java?rev=934201&r1=934200&r2=934201&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java Wed Apr 14 21:23:26 2010
@@ -233,22 +233,4 @@ public class LifecycleDependencyResolver
         return projectKeys;
     }
 
-
-    public void reResolveReactorArtifacts( ProjectBuildList projectBuilds, boolean aggregating, MavenProject project,
-                                           MavenSession session, MavenExecutionPlan executionPlan )
-        throws LifecycleExecutionException
-    {
-        final Set<String> reactorProjectKeys = projectBuilds.getReactorProjectKeys();
-        final Set<Artifact> artifactSet = project.getArtifacts();
-        for ( Artifact artifact : artifactSet )
-        {
-            String key = ArtifactUtils.key( artifact );
-            if ( reactorProjectKeys.contains( key ) )
-            {
-                artifact.setResolved( false );
-            }
-
-        }
-        resolveDependencies( aggregating, project, session, executionPlan );
-    }
 }

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleExecutionPlanCalculatorImpl.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleExecutionPlanCalculatorImpl.java?rev=934201&r1=934200&r2=934201&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleExecutionPlanCalculatorImpl.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleExecutionPlanCalculatorImpl.java Wed Apr 14 21:23:26 2010
@@ -92,7 +92,7 @@ public class LifecycleExecutionPlanCalcu
         final List<ExecutionPlanItem> planItem = defaultLifeCycles.createExecutionPlanItem( project, executions );
 
         return new MavenExecutionPlan( requiredDependencyResolutionScopes, requiredDependencyCollectionScopes,
-                                       planItem );
+                                       planItem, defaultLifeCycles );
 
 
     }

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleWeaveBuilder.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleWeaveBuilder.java?rev=934201&r1=934200&r2=934201&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleWeaveBuilder.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleWeaveBuilder.java Wed Apr 14 21:23:26 2010
@@ -18,13 +18,21 @@ import org.apache.maven.execution.BuildS
 import org.apache.maven.execution.ExecutionEvent;
 import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.MavenSession;
-import org.apache.maven.lifecycle.*;
+import org.apache.maven.lifecycle.LifecycleExecutionException;
+import org.apache.maven.lifecycle.MavenExecutionPlan;
+import org.apache.maven.lifecycle.Schedule;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.logging.Logger;
 
-import java.util.*;
+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.Properties;
 import java.util.concurrent.Callable;
 import java.util.concurrent.CompletionService;
 import java.util.concurrent.ExecutionException;
@@ -62,9 +70,6 @@ public class LifecycleWeaveBuilder
     private Logger logger;
 
     @Requirement
-    private LifecycleDependencyResolver lifecycleDependencyResolver;
-
-    @Requirement
     private ExecutionEventCatapult eventCatapult;
 
     private final Map<MavenProject, MavenExecutionPlan> executionPlans =
@@ -77,17 +82,17 @@ public class LifecycleWeaveBuilder
     }
 
     public LifecycleWeaveBuilder( MojoExecutor mojoExecutor, BuilderCommon builderCommon, Logger logger,
-                                  LifecycleDependencyResolver lifecycleDependencyResolver, ExecutionEventCatapult eventCatapult )
+                                  ExecutionEventCatapult eventCatapult )
     {
         this.mojoExecutor = mojoExecutor;
         this.builderCommon = builderCommon;
         this.logger = logger;
-        this.lifecycleDependencyResolver = lifecycleDependencyResolver;
         this.eventCatapult = eventCatapult;
     }
 
     public void build( ProjectBuildList projectBuilds, ReactorContext buildContext, List<TaskSegment> taskSegments,
-                       MavenSession session, CompletionService<ProjectSegment> service, ReactorBuildStatus reactorBuildStatus )
+                       MavenSession session, CompletionService<ProjectSegment> service,
+                       ReactorBuildStatus reactorBuildStatus )
         throws ExecutionException, InterruptedException
     {
         ConcurrentBuildLogger concurrentBuildLogger = new ConcurrentBuildLogger();
@@ -97,7 +102,7 @@ public class LifecycleWeaveBuilder
 
             for ( TaskSegment taskSegment : taskSegments )
             {
-                ProjectBuildList segmentChunks = projectBuilds.getByTaskSegment(  taskSegment );
+                ProjectBuildList segmentChunks = projectBuilds.getByTaskSegment( taskSegment );
                 ThreadOutputMuxer muxer = null;  // new ThreadOutputMuxer( segmentChunks, System.out );
                 for ( ProjectSegment projectBuild : segmentChunks )
                 {
@@ -113,8 +118,7 @@ public class LifecycleWeaveBuilder
                         final Callable<ProjectSegment> projectBuilder =
                             createCallableForBuildingOneFullModule( buildContext, session, reactorBuildStatus,
                                                                     executionPlan, projectBuild, muxer,
-                                                                    dependencyContext, concurrentBuildLogger,
-                                                                    projectBuilds );
+                                                                    dependencyContext, concurrentBuildLogger );
 
                         futures.add( service.submit( projectBuilder ) );
                     }
@@ -140,14 +144,13 @@ public class LifecycleWeaveBuilder
     }
 
     private Callable<ProjectSegment> createCallableForBuildingOneFullModule( final ReactorContext reactorContext,
-                                                                           final MavenSession rootSession,
-                                                                           final ReactorBuildStatus reactorBuildStatus,
-                                                                           final MavenExecutionPlan executionPlan,
-                                                                           final ProjectSegment projectBuild,
-                                                                           final ThreadOutputMuxer muxer,
-                                                                           final DependencyContext dependencyContext,
-                                                                           final ConcurrentBuildLogger concurrentBuildLogger,
-                                                                           final ProjectBuildList projectBuilds )
+                                                                             final MavenSession rootSession,
+                                                                             final ReactorBuildStatus reactorBuildStatus,
+                                                                             final MavenExecutionPlan executionPlan,
+                                                                             final ProjectSegment projectBuild,
+                                                                             final ThreadOutputMuxer muxer,
+                                                                             final DependencyContext dependencyContext,
+                                                                             final ConcurrentBuildLogger concurrentBuildLogger )
     {
         return new Callable<ProjectSegment>()
         {
@@ -168,27 +171,13 @@ public class LifecycleWeaveBuilder
 
                 eventCatapult.fire( ExecutionEvent.Type.ProjectStarted, projectBuild.getSession(), null );
 
-                boolean packagePhaseSeen = false;
-                boolean runBAbyRun = false;
                 try
                 {
                     while ( current != null && !reactorBuildStatus.isHalted() &&
                         !reactorBuildStatus.isBlackListed( projectBuild.getProject() ) )
                     {
-                        final String phase = current.getMojoExecution().getMojoDescriptor().getPhase();
                         PhaseRecorder phaseRecorder = new PhaseRecorder( projectBuild.getProject() );
 
-                        if ( !packagePhaseSeen && phase != null && phase.equals( "package" ) )
-                        {
-                            // Re-resolve. A bit of a kludge ATM
-                            packagePhaseSeen = true;
-                            lifecycleDependencyResolver.reResolveReactorArtifacts( projectBuilds, false,
-                                                                                   projectBuild.getProject(),
-                                                                                   projectBuild.getSession(),
-                                                                                   executionPlan );
-
-                        }
-
                         BuiltLogItem builtLogItem =
                             concurrentBuildLogger.createBuildLogItem( projectBuild.getProject(), current );
                         final Schedule schedule = current.getSchedule();
@@ -210,16 +199,17 @@ public class LifecycleWeaveBuilder
                         current.setComplete();
                         builtLogItem.setComplete();
 
-                        ExecutionPlanItem next = planItems.hasNext() ? planItems.next() : null;
-                        if ( next != null )
+                        ExecutionPlanItem nextPlanItem = planItems.hasNext() ? planItems.next() : null;
+                        if ( nextPlanItem != null )
                         {
-                            final Schedule scheduleOfNext = next.getSchedule();
-                            if ( !runBAbyRun && ( scheduleOfNext == null || !scheduleOfNext.isParallel() ) )
+                            final Schedule scheduleOfNext = nextPlanItem.getSchedule();
+                            if ( scheduleOfNext == null || !scheduleOfNext.isParallel() )
                             {
                                 for ( MavenProject upstreamProject : projectBuild.getImmediateUpstreamProjects() )
                                 {
                                     final MavenExecutionPlan upstreamPlan = executionPlans.get( upstreamProject );
-                                    final ExecutionPlanItem inSchedule = upstreamPlan.findLastInPhase( next );
+                                    final String nextPhase = nextPlanItem.getLifecyclePhase();
+                                    final ExecutionPlanItem inSchedule = upstreamPlan.findLastInPhase( nextPhase );
                                     if ( inSchedule != null )
                                     {
                                         long startWait = System.currentTimeMillis();
@@ -229,12 +219,7 @@ public class LifecycleWeaveBuilder
                                 }
                             }
                         }
-                        current = next;
-
-                        if ( packagePhaseSeen && !runBAbyRun )
-                        {
-                            runBAbyRun = true;
-                        }
+                        current = nextPlanItem;
                     }
 
                     final long wallClockTime = System.currentTimeMillis() - buildStartTime;

Modified: maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/MavenExecutionPlanTest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/MavenExecutionPlanTest.java?rev=934201&r1=934200&r2=934201&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/MavenExecutionPlanTest.java (original)
+++ maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/MavenExecutionPlanTest.java Wed Apr 14 21:23:26 2010
@@ -13,7 +13,6 @@
  * the License.
  */
 
-
 package org.apache.maven.lifecycle;
 
 import junit.framework.TestCase;
@@ -33,9 +32,9 @@ public class MavenExecutionPlanTest
     public void testFindFirstWithMatchingSchedule()
         throws Exception
     {
-        MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan();
         final List<Scheduling> cycles = DefaultLifecyclesStub.getSchedulingList();
         final Schedule schedule = cycles.get( 0 ).getSchedules().get( 0 );
+        assertNotNull( schedule);
 
     }
 
@@ -49,4 +48,33 @@ public class MavenExecutionPlanTest
         assertFalse( planItemIterator.next().ensureComplete() );
     }
 
+    public void testFindLastInPhase()
+        throws Exception
+    {
+        MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan();
+
+        ExecutionPlanItem expected = plan.findLastInPhase( "package" );
+        ExecutionPlanItem beerPhase = plan.findLastInPhase( "BEER" );  // Beer comes straight after package in stub
+        assertEquals( expected, beerPhase );
+        assertNotNull( expected );
+    }
+
+    public void testFindLastWhenFirst()
+        throws Exception
+    {
+        MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan();
+
+        ExecutionPlanItem beerPhase = plan.findLastInPhase(  LifecycleExecutionPlanCalculatorStub.VALIDATE.getPhase());  // Beer comes straight after package in stub
+        assertNull ( beerPhase);
+    }
+
+    public void testFindLastInPhaseMisc()
+        throws Exception
+    {
+        MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan();
+
+        assertNull( plan.findLastInPhase( "pacXkage" ));
+         // Beer comes straight after package in stub, much like real life.
+        assertNotNull(  plan.findLastInPhase(  LifecycleExecutionPlanCalculatorStub.INITIALIZE.getPhase()));
+    }
 }

Modified: maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/LifecycleWeaveBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/LifecycleWeaveBuilderTest.java?rev=934201&r1=934200&r2=934201&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/LifecycleWeaveBuilderTest.java (original)
+++ maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/LifecycleWeaveBuilderTest.java Wed Apr 14 21:23:26 2010
@@ -122,8 +122,7 @@ public class LifecycleWeaveBuilderTest
         final LoggerStub loggerStub = new LoggerStub();
         final LifecycleDependencyResolver lifecycleDependencyResolver =
             new LifecycleDependencyResolver( new ProjectDependenciesResolverStub(), loggerStub );
-        return new LifecycleWeaveBuilder( mojoExecutor, builderCommon, loggerStub, lifecycleDependencyResolver,
-                                          new ExecutionEventCatapultStub() );
+        return new LifecycleWeaveBuilder( mojoExecutor, builderCommon, loggerStub, new ExecutionEventCatapultStub() );
     }
 
     private BuilderCommon getBuilderCommon()

Modified: maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/DefaultLifecyclesStub.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/DefaultLifecyclesStub.java?rev=934201&r1=934200&r2=934201&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/DefaultLifecyclesStub.java (original)
+++ maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/DefaultLifecyclesStub.java Wed Apr 14 21:23:26 2010
@@ -15,13 +15,19 @@
 
 package org.apache.maven.lifecycle.internal.stub;
 
-import java.util.Arrays;
-import java.util.List;
-
 import org.apache.maven.lifecycle.DefaultLifecycles;
 import org.apache.maven.lifecycle.Lifecycle;
 import org.apache.maven.lifecycle.Schedule;
 import org.apache.maven.lifecycle.Scheduling;
+import org.omg.CORBA.INITIALIZE;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub.*;
 
 /**
  * @author Kristian Rosenvold
@@ -31,12 +37,31 @@ public class DefaultLifecyclesStub
 {
     public static DefaultLifecycles createDefaultLifeCycles()
     {
-        final Lifecycle lifecycle1 = new Lifecycle( "abc", Arrays.asList( "compile" ), null );
-        final Lifecycle lifecycle2 = new Lifecycle( "abc", Arrays.asList( "test" ), null );
-        final List<Lifecycle> lifeCycles = Arrays.asList( lifecycle1, lifecycle2 );
+
+        List<String> stubDefaultCycle =
+            Arrays.asList( VALIDATE.getPhase(), INITIALIZE.getPhase(), PROCESS_RESOURCES.getPhase(), COMPILE.getPhase(),
+                           TEST.getPhase(), PROCESS_TEST_RESOURCES.getPhase(), PACKAGE.getPhase(), "BEER",
+                           INSTALL.getPhase() );
+
+        // The two phases below are really for future expansion, some would say they lack a drink
+        // The point being that they do not really have to match the "real" stuff,
+        List<String> stubCleanCycle =
+            Arrays.asList( PRE_CLEAN.getPhase(), CLEAN.getPhase(), POST_CLEAN.getPhase() );
+
+        List<String> stubSiteCycle =
+            Arrays.asList( PRE_SITE.getPhase(), SITE.getPhase(), POST_SITE.getPhase(), SITE_DEPLOY.getPhase());
+
+        Iterator<List<String>> lcs = Arrays.asList( stubDefaultCycle, stubCleanCycle, stubSiteCycle ).iterator();
+
+        Map<String, Lifecycle> lifeCycles = new HashMap<String, Lifecycle>();
+        for ( String s : DefaultLifecycles.STANDARD_LIFECYCLES )
+        {
+            final Lifecycle lifecycle = new Lifecycle( s, lcs.next(), null );
+            lifeCycles.put( s, lifecycle );
+
+        }
         final List<Scheduling> schedulingList = getSchedulingList();
-        final DefaultLifecycles defaultLifecycles = new DefaultLifecycles( lifeCycles, schedulingList );
-        return defaultLifecycles;
+        return new DefaultLifecycles( lifeCycles, schedulingList, new LoggerStub() );
     }
 
     public static List<Scheduling> getSchedulingList()

Modified: maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifecycleExecutionPlanCalculatorStub.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifecycleExecutionPlanCalculatorStub.java?rev=934201&r1=934200&r2=934201&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifecycleExecutionPlanCalculatorStub.java (original)
+++ maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifecycleExecutionPlanCalculatorStub.java Wed Apr 14 21:23:26 2010
@@ -49,10 +49,16 @@ import java.util.Set;
 public class LifecycleExecutionPlanCalculatorStub
     implements LifecycleExecutionPlanCalculator
 {
+    // clean
+    public final static MojoDescriptor PRE_CLEAN = createMojoDescriptor( "pre-clean" );
     public final static MojoDescriptor CLEAN = createMojoDescriptor( "clean" );
+    public final static MojoDescriptor POST_CLEAN = createMojoDescriptor( "post-clean" );
 
+    // default (or at least some of them)
     public final static MojoDescriptor VALIDATE = createMojoDescriptor( "validate" );
 
+    public final static MojoDescriptor INITIALIZE = createMojoDescriptor( "initialize" );
+    
     public final static MojoDescriptor TEST_COMPILE = createMojoDescriptor( "test-compile" );
 
     public final static MojoDescriptor PROCESS_TEST_RESOURCES = createMojoDescriptor( "process-test-resources" );
@@ -67,6 +73,15 @@ public class LifecycleExecutionPlanCalcu
 
     public final static MojoDescriptor INSTALL = createMojoDescriptor( "install" );
 
+
+    // site
+    public final static MojoDescriptor PRE_SITE = createMojoDescriptor( "pre-site" );
+    public final static MojoDescriptor SITE = createMojoDescriptor( "site" );
+    public final static MojoDescriptor POST_SITE = createMojoDescriptor( "post-site" );
+    public final static MojoDescriptor SITE_DEPLOY = createMojoDescriptor( "site-deploy" );
+
+
+
     public int getNumberOfExceutions( ProjectBuildList projectBuildList )
         throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException,
         NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException,
@@ -99,9 +114,7 @@ public class LifecycleExecutionPlanCalcu
         List<MojoExecution> me = new ArrayList<MojoExecution>();
         me.add( createMojoExecution( new Plugin(), "resources", "default-resources", PROCESS_RESOURCES ) );
         me.add( createMojoExecution( new Plugin(), "compile", "default-compile", COMPILE ) );
-        return new MavenExecutionPlan( getScopes(), getScopes(),
-                                       DefaultLifecyclesStub.createDefaultLifeCycles().createExecutionPlanItem( project,
-                                                                                                                me ) );
+        return createExecutionPlan( project, me );
     }
 
     public static MavenExecutionPlan getProjectAExceutionPlan()
@@ -110,7 +123,7 @@ public class LifecycleExecutionPlanCalcu
         NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException
     {
         List<MojoExecution> me = new ArrayList<MojoExecution>();
-        me.add( createMojoExecution( new Plugin(), "enforce", "enforce-versions", VALIDATE ) );
+        me.add( createMojoExecution( new Plugin(), "initialize", "default-initialize", INITIALIZE ) ); 
         me.add( createMojoExecution( new Plugin(), "resources", "default-resources", PROCESS_RESOURCES ) );
         me.add( createMojoExecution( new Plugin(), "compile", "default-compile", COMPILE ) );
         me.add( createMojoExecution( new Plugin(), "testResources", "default-testResources", PROCESS_TEST_RESOURCES ) );
@@ -118,12 +131,10 @@ public class LifecycleExecutionPlanCalcu
         me.add( createMojoExecution( new Plugin(), "test", "default-test", TEST ) );
         me.add( createMojoExecution( new Plugin(), "war", "default-war", PACKAGE ) );
         me.add( createMojoExecution( new Plugin(), "install", "default-install", INSTALL ) );
-        final List<ExecutionPlanItem> executionPlanItem =
-            DefaultLifecyclesStub.createDefaultLifeCycles().createExecutionPlanItem(
-                ProjectDependencyGraphStub.A.getExecutionProject(), me );
-        return new MavenExecutionPlan( getScopes(), getScopes(), executionPlanItem );
+        return createExecutionPlan( ProjectDependencyGraphStub.A.getExecutionProject(), me );
     }
 
+
     public static MavenExecutionPlan getProjectBExecutionPlan()
         throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException,
         PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
@@ -136,10 +147,19 @@ public class LifecycleExecutionPlanCalcu
         me.add( createMojoExecution( new Plugin(), "testResources", "default-testResources", PROCESS_TEST_RESOURCES ) );
         me.add( createMojoExecution( new Plugin(), "testCompile", "default-testCompile", TEST_COMPILE ) );
         me.add( createMojoExecution( new Plugin(), "test", "default-test", TEST ) );
-        final List<ExecutionPlanItem> planItem =
-            DefaultLifecyclesStub.createDefaultLifeCycles().createExecutionPlanItem(
-                ProjectDependencyGraphStub.B.getExecutionProject(), me );
-        return new MavenExecutionPlan( getScopes(), getScopes(), planItem );
+        return createExecutionPlan( ProjectDependencyGraphStub.B.getExecutionProject(), me );
+    }
+
+
+    private static MavenExecutionPlan createExecutionPlan( MavenProject project, List<MojoExecution> mojoExecutions )
+        throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException,
+        NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException,
+        LifecyclePhaseNotFoundException, LifecycleNotFoundException
+    {
+        final List<ExecutionPlanItem> planItemList =
+            DefaultLifecyclesStub.createDefaultLifeCycles().createExecutionPlanItem( project, mojoExecutions );
+        return new MavenExecutionPlan( getScopes(), getScopes(), planItemList,
+                                       DefaultLifecyclesStub.createDefaultLifeCycles() );
     }
 
     private static MojoExecution createMojoExecution( Plugin plugin, String goal, String executionId,

Modified: maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java?rev=934201&r1=934200&r2=934201&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java (original)
+++ maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java Wed Apr 14 21:23:26 2010
@@ -55,7 +55,7 @@ public class EmptyLifecycleExecutor
         throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
         MojoNotFoundException
     {
-        return new MavenExecutionPlan(null, null, null );
+        return new MavenExecutionPlan(null, null, null, null );
     }
 
     public void execute( MavenSession session )