o clean lifecycle is handled by defaults populator

git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@776540 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-05-20 04:25:59 +00:00
parent ed8dbbdc8d
commit 9dfca575c7
3 changed files with 26 additions and 48 deletions

View File

@ -42,10 +42,8 @@ import org.apache.maven.artifact.transform.ArtifactTransformationManager;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.events.TransferListener;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.FileUtils;

View File

@ -267,24 +267,6 @@ public class DefaultLifecycleExecutor
// on to the given phases in the lifecycle are going to be a little different then, say, a project of type JAR.
//
Map<String, String> lifecyclePhasesForPackaging;
if ( task.equals( "clean" ) )
{
lifecyclePhasesForPackaging = new HashMap<String, String>();
for ( String phase : lifecycle.getDefaultPhases() )
{
lifecyclePhasesForPackaging.put( "clean", "org.apache.maven.plugins:maven-clean-plugin:clean" );
}
}
else
{
LifecycleMapping lifecycleMappingForPackaging = lifecycleMappings.get( project.getPackaging() );
lifecyclePhasesForPackaging = lifecycleMappingForPackaging.getLifecycles().get( lifecycle.getId() ).getPhases();
}
// 3.
//
// Once we have the lifecycle mapping for the given packaging, we need to know whats phases we need to worry about executing.
@ -300,7 +282,12 @@ public class DefaultLifecycleExecutor
for ( String phase : lifecycle.getPhases() )
{
List<String> mojos = new ArrayList<String>();
if ( phase.equals( "clean" ) )
{
mojos.add( "org.apache.maven.plugins:maven-clean-plugin:clean" );
}
// This is just just laying out the initial structure of the mojos to run in each phase of the
// lifecycle. Everything is now done in the project builder correctly so this could likely
// go away shortly. We no longer need to pull out bits from the default lifecycle. The MavenProject
@ -384,31 +371,6 @@ public class DefaultLifecycleExecutor
MojoExecution mojoExecution = getMojoExecution( project, mojoDescriptor );
/*
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
String g = mojoExecution.getMojoDescriptor().getPluginDescriptor().getGroupId();
String a = mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId();
Plugin p = project.getPlugin( g + ":" + a );
for ( PluginExecution e : p.getExecutions() )
{
for ( String goal : e.getGoals() )
{
if ( mojoDescriptor.getGoal().equals( goal ) )
{
Xpp3Dom executionConfiguration = (Xpp3Dom) e.getConfiguration();
Xpp3Dom mojoConfiguration = extractMojoConfiguration( executionConfiguration, mojoDescriptor );
mojoExecution.setConfiguration( mojoConfiguration );
}
}
}
*/
lifecyclePlan.add( mojoExecution );
}
}

View File

@ -71,7 +71,25 @@ public class LifecycleExecutorTest
assertEquals( "2.3", mojoExecution.getMojoDescriptor().getPluginDescriptor().getVersion() );
}
public void testCalculationOfBuildPlanWithIndividualTaskWherePluginIsNotSpecifiedInThePom()
public void testCalculationOfBuildPlanWithIndividualTaskOfTheCleanLifecycle()
throws Exception
{
// We are doing something like "mvn clean:clean" where no version is specified but this
// project we are working on has the version specified in the POM so the version should come from there.
File pom = getProject( "project-with-additional-lifecycle-elements" );
MavenSession session = createMavenSession( pom );
assertEquals( "project-with-additional-lifecycle-elements", session.getCurrentProject().getArtifactId() );
assertEquals( "1.0", session.getCurrentProject().getVersion() );
List<MojoExecution> lifecyclePlan = lifecycleExecutor.calculateBuildPlan( "clean", session );
assertEquals( 1, lifecyclePlan.size() );
MojoExecution mojoExecution = lifecyclePlan.get( 0 );
assertNotNull( mojoExecution );
assertEquals( "org.apache.maven.plugins", mojoExecution.getMojoDescriptor().getPluginDescriptor().getGroupId() );
assertEquals( "maven-clean-plugin", mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId() );
assertEquals( "2.2", mojoExecution.getMojoDescriptor().getPluginDescriptor().getVersion() );
}
public void testCalculationOfBuildPlanWithIndividualTaskOfTheCleanCleanGoal()
throws Exception
{
// We are doing something like "mvn clean:clean" where no version is specified but this
@ -88,7 +106,7 @@ public class LifecycleExecutorTest
assertEquals( "maven-clean-plugin", mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId() );
assertEquals( "2.2", mojoExecution.getMojoDescriptor().getPluginDescriptor().getVersion() );
}
public void testLifecycleQueryingUsingADefaultLifecyclePhase()
throws Exception
{