o trying to figure out what calls are most useful in something like m2e that is going to make a hyper-optimized lifecycle

based on what's required in the IDE versus the CLI


git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@757504 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-03-23 19:06:48 +00:00
parent ecf09e66f5
commit 560d47dccb
2 changed files with 41 additions and 37 deletions

View File

@ -24,6 +24,7 @@ import java.util.Map;
import java.util.StringTokenizer;
import org.apache.maven.BuildFailureException;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.ReactorManager;
import org.apache.maven.lifecycle.mapping.LifecycleMapping;
@ -40,6 +41,11 @@ import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
//TODO: The configuration for the lifecycle needs to be externalized so that I can use the annotations
// properly for the wiring and reference and external source for the lifecycle configuration.
//TODO: Inside an IDE we are replacing the notion of our reactor with a workspace. In both of these cases
// we need to layer these as local repositories.
/**
* @author Jason van Zyl
*/
@ -52,13 +58,14 @@ public class DefaultLifecycleExecutor
@Requirement
private PluginManager pluginManager;
@Requirement
private Map<String, LifecycleMapping> lifecycleMappings;
// @Configuration(source="org/apache/maven/lifecycle/lifecycles.xml")
private List<Lifecycle> lifecycles;
private Map<String, Lifecycle> phaseToLifecycleMap;
@Requirement
private Map<String, LifecycleMapping> lifecycleMappings;
public void execute( MavenSession session )
throws BuildFailureException, LifecycleExecutionException
{
@ -108,12 +115,8 @@ public class DefaultLifecycleExecutor
{
if ( !session.getReactorManager().isBlackListed( currentProject ) )
{
line();
logger.info( "Building " + currentProject.getName() );
line();
// !! This is ripe for refactoring to an aspect.
// Event monitoring.
String event = MavenEvents.PROJECT_EXECUTION;
@ -294,6 +297,22 @@ public class DefaultLifecycleExecutor
*/
}
//TODO: which form is most useful. passing in string to parse is not really good.
MojoDescriptor getMojoDescriptor( Artifact pluginArtifact, String goal, MavenSession session, MavenProject project )
throws LifecycleExecutionException
{
return null;
}
MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version, String goal, MavenSession session, MavenProject project )
throws LifecycleExecutionException
{
return null;
}
// org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process
MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProject project )
throws LifecycleExecutionException
{
@ -376,11 +395,6 @@ public class DefaultLifecycleExecutor
return mojoDescriptor;
}
protected void line()
{
logger.info( "------------------------------------------------------------------------" );
}
private PluginDescriptor loadPlugin( Plugin plugin, MavenProject project, MavenSession session )
throws LifecycleExecutionException
{

View File

@ -89,13 +89,10 @@ public class LifecycleExecutorTest
File sourceDirectory = new File( getBasedir(), "src/test/" + base );
File targetDirectory = new File( getBasedir(), "target/" + base );
FileUtils.copyDirectoryStructure( sourceDirectory, targetDirectory );
File targetPom = new File( targetDirectory, "pom.xml" );
MavenSession session = createMavenSession( targetPom );
File targetPom = new File( targetDirectory, "pom.xml" );
MavenSession session = createMavenSession( targetPom );
assertEquals( "project-with-additional-lifecycle-elements", session.getCurrentProject().getArtifactId() );
assertEquals( "1.0-SNAPSHOT", session.getCurrentProject().getVersion() );
assertEquals( "1.0-SNAPSHOT", session.getCurrentProject().getVersion() );
lifecycleExecutor.execute( session );
}
@ -107,19 +104,11 @@ public class LifecycleExecutorTest
throws Exception
{
MavenSession session = createMavenSession( targetPom );
String pluginArtifactId = "remote-resources";
String goal = "process";
MojoDescriptor mojoDescriptor = lifecycleExecutor.getMojoDescriptor( pluginArtifactId + ":" + goal, session, session.getCurrentProject() );
PluginDescriptor pd = mojoDescriptor.getPluginDescriptor();
assertNotNull( pd );
assertEquals( "org.apache.maven.plugins", pd.getGroupId() );
assertEquals( "maven-remote-resources-plugin", pd.getArtifactId() );
assertEquals( "1.0", pd.getVersion() );
assertPluginDescriptor( mojoDescriptor, "org.apache.maven.plugins", "maven-remote-resources-plugin", "1.0" );
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
pluginManager.executeMojo( session.getCurrentProject(), mojoExecution, session );
}
@ -127,20 +116,11 @@ public class LifecycleExecutorTest
throws Exception
{
MavenSession session = createMavenSession( targetPom );
String pluginArtifactId = "surefire";
String goal = "test";
MojoDescriptor mojoDescriptor = lifecycleExecutor.getMojoDescriptor( pluginArtifactId + ":" + goal, session, session.getCurrentProject() );
assertNotNull( mojoDescriptor );
PluginDescriptor pd = mojoDescriptor.getPluginDescriptor();
assertNotNull( pd );
assertEquals( "org.apache.maven.plugins", pd.getGroupId() );
assertEquals( "maven-surefire-plugin", pd.getArtifactId() );
assertEquals( "2.4.2", pd.getVersion() );
assertPluginDescriptor( mojoDescriptor, "org.apache.maven.plugins", "maven-surefire-plugin", "2.4.2" );
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
pluginManager.executeMojo( session.getCurrentProject(), mojoExecution, session );
}
@ -148,6 +128,16 @@ public class LifecycleExecutorTest
// Testing help
// -----------------------------------------------------------------------------------------------
protected void assertPluginDescriptor( MojoDescriptor mojoDescriptor, String groupId, String artifactId, String version )
{
assertNotNull( mojoDescriptor );
PluginDescriptor pd = mojoDescriptor.getPluginDescriptor();
assertNotNull( pd );
assertEquals( groupId, pd.getGroupId() );
assertEquals( artifactId, pd.getArtifactId() );
assertEquals( version, pd.getVersion() );
}
/**
* We need to customize the standard Plexus container with the plugin discovery listener which
* is what looks for the META-INF/maven/plugin.xml resources that enter the system when a