You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2009/05/21 16:00:35 UTC
svn commit: r777120 - in /maven/components/branches/MNG-2766:
maven-core/src/main/java/org/apache/maven/lifecycle/
maven-core/src/main/java/org/apache/maven/plugin/
maven-core/src/test/java/org/apache/maven/lifecycle/
maven-model-builder/src/main/resou...
Author: jvanzyl
Date: Thu May 21 14:00:34 2009
New Revision: 777120
URL: http://svn.apache.org/viewvc?rev=777120&view=rev
Log:
o using mojo executions as the placeholders in the lifecycle instead of string representations
Modified:
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java
maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
maven/components/branches/MNG-2766/maven-model-builder/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=777120&r1=777119&r2=777120&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Thu May 21 14:00:34 2009
@@ -227,7 +227,7 @@
{
MavenProject project = session.getCurrentProject();
- List<String> phasesWithMojosToExecute = new ArrayList<String>();
+ List<MojoExecution> phasesWithMojosToExecute = new ArrayList<MojoExecution>();
List<MojoExecution> lifecyclePlan = new ArrayList<MojoExecution>();
@@ -238,7 +238,9 @@
{
MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session );
- MojoExecution mojoExecution = getMojoExecution( project, mojoDescriptor );
+ MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
+
+ populateMojoExecutionConfiguration( project, mojoExecution );
lifecyclePlan.add( mojoExecution );
}
@@ -265,7 +267,7 @@
//
// Create an ordered Map of the phases in the lifecycle to a list of mojos to execute.
- Map<String, List<String>> phaseToMojoMapping = new LinkedHashMap<String, List<String>>();
+ Map<String, List<MojoExecution>> phaseToMojoMapping = new LinkedHashMap<String, List<MojoExecution>>();
// 4.
@@ -273,11 +275,12 @@
for ( String phase : lifecycle.getPhases() )
{
- List<String> mojos = new ArrayList<String>();
+ List<MojoExecution> mojos = new ArrayList<MojoExecution>();
+ //TODO: remove hard coding
if ( phase.equals( "clean" ) )
{
- mojos.add( "org.apache.maven.plugins:maven-clean-plugin:clean" );
+ mojos.add( new MojoExecution( "org.apache.maven.plugins", "maven-clean-plugin", "2.3", "clean", null ) );
}
// This is just just laying out the initial structure of the mojos to run in each phase of the
@@ -310,10 +313,11 @@
// So for the lifecycle mapping we need a map with the phases as keys so we can easily check
// if this phase belongs to the given lifecycle. this shows the system is messed up. this
// shouldn't happen.
- phaseToMojoMapping.put( execution.getPhase(), new ArrayList<String>() );
+ phaseToMojoMapping.put( execution.getPhase(), new ArrayList<MojoExecution>() );
}
- phaseToMojoMapping.get( execution.getPhase() ).add( s );
+ MojoExecution mojoExecution = new MojoExecution( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), goal, execution.getId() );
+ phaseToMojoMapping.get( execution.getPhase() ).add( mojoExecution );
}
}
// if not then i need to grab the mojo descriptor and look at the phase that is specified
@@ -326,7 +330,8 @@
if ( mojoDescriptor.getPhase() != null && phaseToMojoMapping.get( mojoDescriptor.getPhase() ) != null )
{
- phaseToMojoMapping.get( mojoDescriptor.getPhase() ).add( s );
+ MojoExecution mojoExecution = new MojoExecution( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), goal, execution.getId() );
+ phaseToMojoMapping.get( mojoDescriptor.getPhase() ).add( mojoExecution );
}
}
}
@@ -338,7 +343,6 @@
// We are only interested in the phases that correspond to the lifecycle we are trying to run. If we are running the "clean"
// lifecycle we are not interested in goals -- like "generate-sources -- that belong to the default lifecycle.
//
-
for ( String phase : phaseToMojoMapping.keySet() )
{
phasesWithMojosToExecute.addAll( phaseToMojoMapping.get( phase ) );
@@ -354,17 +358,19 @@
// 7. Now we create the correct configuration for the mojo to execute.
//TODO: this needs to go to the model builder.
-
- for ( String mojo : phasesWithMojosToExecute )
+ //TODO: just used a hollowed out MojoExecution
+ for ( MojoExecution mojoExecution : phasesWithMojosToExecute )
{
// These are bits that look like this:
//
// org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process
- //
-
- MojoDescriptor mojoDescriptor = getMojoDescriptor( mojo, session );
+ //
+ MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor(
+ mojoExecution.getGroupId(), mojoExecution.getArtifactId(), mojoExecution.getVersion(), mojoExecution.getGoal(), session.getLocalRepository(), project.getRemoteArtifactRepositories() );
- MojoExecution mojoExecution = getMojoExecution( project, mojoDescriptor );
+ mojoExecution.setMojoDescriptor( mojoDescriptor );
+
+ populateMojoExecutionConfiguration( project, mojoExecution );
lifecyclePlan.add( mojoExecution );
}
@@ -380,13 +386,13 @@
return sb.toString();
}
- private MojoExecution getMojoExecution( MavenProject project, MojoDescriptor mojoDescriptor )
- {
- MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
-
- String g = mojoDescriptor.getPluginDescriptor().getGroupId();
+ //this will get the wrong configuration because it's only matching the goal not the execution id
+
+ private void populateMojoExecutionConfiguration( MavenProject project, MojoExecution mojoExecution )
+ {
+ String g = mojoExecution.getGroupId();
- String a = mojoDescriptor.getPluginDescriptor().getArtifactId();
+ String a = mojoExecution.getArtifactId();
Plugin p = project.getPlugin( g + ":" + a );
@@ -394,18 +400,16 @@
{
for ( String goal : e.getGoals() )
{
- if ( mojoDescriptor.getGoal().equals( goal ) )
+ if ( mojoExecution.getGoal().equals( goal ) )
{
Xpp3Dom executionConfiguration = (Xpp3Dom) e.getConfiguration();
- Xpp3Dom mojoConfiguration = extractMojoConfiguration( executionConfiguration, mojoDescriptor );
+ Xpp3Dom mojoConfiguration = extractMojoConfiguration( executionConfiguration, mojoExecution.getMojoDescriptor() );
mojoExecution.setConfiguration( mojoConfiguration );
}
}
}
-
- return mojoExecution;
}
Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java?rev=777120&r1=777119&r2=777120&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java Thu May 21 14:00:34 2009
@@ -22,26 +22,37 @@
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.codehaus.plexus.util.xml.Xpp3Dom;
-/**
- * Describes a single mojo invocation.
- *
- * @author <a href="mailto:brett@apache.org">Brett Porter</a>
- * @version $Id$
- */
public class MojoExecution
{
- private final String executionId;
-
- private final MojoDescriptor mojoDescriptor;
+ private String groupId;
+
+ private String artifactId;
+
+ private String version;
+
+ private String goal;
+
+ private String executionId;
+
+ private MojoDescriptor mojoDescriptor;
private Xpp3Dom configuration;
-
+
/**
* The phase may or may not have been bound to a phase but once the plan has been calculated we know what phase
* this mojo execution is going to run in.
*/
private String lifecyclePhase;
+ public MojoExecution( String groupId, String artifactId, String version, String goal, String executionId )
+ {
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.version = version;
+ this.goal = goal;
+ this.executionId = executionId;
+ }
+
public MojoExecution( MojoDescriptor mojoDescriptor )
{
this.mojoDescriptor = mojoDescriptor;
@@ -115,4 +126,48 @@
return buffer.toString();
}
+ public String getGroupId()
+ {
+ if ( mojoDescriptor != null )
+ {
+ return mojoDescriptor.getPluginDescriptor().getGroupId();
+ }
+
+ return groupId;
+ }
+
+ public String getArtifactId()
+ {
+ if ( mojoDescriptor != null )
+ {
+ return mojoDescriptor.getPluginDescriptor().getArtifactId();
+ }
+
+ return artifactId;
+ }
+
+ public String getVersion()
+ {
+ if ( mojoDescriptor != null )
+ {
+ return mojoDescriptor.getPluginDescriptor().getVersion();
+ }
+
+ return version;
+ }
+
+ public String getGoal()
+ {
+ if ( mojoDescriptor != null )
+ {
+ return mojoDescriptor.getGoal();
+ }
+
+ return goal;
+ }
+
+ public void setMojoDescriptor( MojoDescriptor mojoDescriptor )
+ {
+ this.mojoDescriptor = mojoDescriptor;
+ }
}
Modified: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java?rev=777120&r1=777119&r2=777120&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java Thu May 21 14:00:34 2009
@@ -87,7 +87,7 @@
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() );
+ assertEquals( "2.3", mojoExecution.getMojoDescriptor().getPluginDescriptor().getVersion() );
}
// We need to take in multiple lifecycles
Modified: maven/components/branches/MNG-2766/maven-model-builder/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-model-builder/src/main/resources/org/apache/maven/project/pom-4.0.0.xml?rev=777120&r1=777119&r2=777120&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-model-builder/src/main/resources/org/apache/maven/project/pom-4.0.0.xml (original)
+++ maven/components/branches/MNG-2766/maven-model-builder/src/main/resources/org/apache/maven/project/pom-4.0.0.xml Thu May 21 14:00:34 2009
@@ -117,7 +117,7 @@
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
- <version>2.4.2</version>
+ <version>2.5</version>
</plugin>
<plugin>
<artifactId>maven-rar-plugin</artifactId>