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/04/30 01:43:08 UTC
svn commit: r770005 - in
/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven:
lifecycle/ plugin/
Author: jvanzyl
Date: Wed Apr 29 23:43:08 2009
New Revision: 770005
URL: http://svn.apache.org/viewvc?rev=770005&view=rev
Log:
o pushing in configurations for plugins for shane to check
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/lifecycle/LifecycleExecutor.java
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
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=770005&r1=770004&r2=770005&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 Wed Apr 29 23:43:08 2009
@@ -39,11 +39,11 @@
import org.apache.maven.plugin.PluginLoaderException;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.configuration.PlexusConfiguration;
-import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
@@ -173,14 +173,10 @@
private void executeGoal( String task, MavenSession session, MavenProject project )
throws LifecycleExecutionException, MojoFailureException
{
- List<MojoDescriptor> lifecyclePlan = calculateLifecyclePlan( task, session );
+ List<MojoExecution> lifecyclePlan = calculateLifecyclePlan( task, session );
- for ( MojoDescriptor mojoDescriptor : lifecyclePlan )
- {
- MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
-
- System.out.println( mojoExecution.getMojoDescriptor().getGoal() );
-
+ for ( MojoExecution mojoExecution : lifecyclePlan )
+ {
try
{
pluginManager.executeMojo( session, mojoExecution );
@@ -203,7 +199,7 @@
// 3. Find the mojos associated with the lifecycle given the project packaging (jar lifecycle mapping for the default lifecycle)
// 4. Bind those mojos found in the lifecycle mapping for the packaging to the lifecycle
// 5. Bind mojos specified in the project itself to the lifecycle
- public List<MojoDescriptor> calculateLifecyclePlan( String lifecyclePhase, MavenSession session )
+ public List<MojoExecution> calculateLifecyclePlan( String lifecyclePhase, MavenSession session )
throws LifecycleExecutionException
{
// Extract the project from the session
@@ -304,16 +300,21 @@
// need to know if this plugin belongs to a phase in the lifecycle that's running
if ( md.getPhase() != null && lifecycle.getPhases().contains( md.getPhase() ) )
- {
- phaseToMojoMapping.get( md.getPhase() ).add( s );
+ {
+ if ( phaseToMojoMapping.get( md.getPhase() ) != null )
+ {
+ phaseToMojoMapping.get( md.getPhase() ).add( s );
+ }
}
+
+ //TODO Here we need to break when we have reached the desired phase.
}
}
}
}
- List<MojoDescriptor> lifecyclePlan = new ArrayList<MojoDescriptor>();
-
+ List<MojoExecution> lifecyclePlan = new ArrayList<MojoExecution>();
+
// We need to turn this into a set of MojoExecutions
for( List<String> mojos : phaseToMojoMapping.values() )
{
@@ -323,7 +324,28 @@
//
// org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process
//
- lifecyclePlan.add( getMojoDescriptor( mojo, project, session.getLocalRepository() ) );
+ MojoDescriptor mojoDescriptor = getMojoDescriptor( mojo, project, session.getLocalRepository() );
+
+ 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 ) )
+ {
+ mojoExecution.setConfiguration( (Xpp3Dom) e.getConfiguration() );
+ }
+ }
+ }
+
+ lifecyclePlan.add( mojoExecution );
}
}
@@ -541,27 +563,29 @@
public Xpp3Dom getDefaultPluginConfiguration( String groupId, String artifactId, String version, String goal, MavenProject project, ArtifactRepository localRepository )
throws LifecycleExecutionException
{
- return convert( getMojoDescriptor( groupId+":"+artifactId+":"+version+":"+goal, project, localRepository ).getMojoConfiguration() );
+ return convert( getMojoDescriptor( groupId+":"+artifactId+":"+version+":"+goal, project, localRepository ) );
}
public Xpp3Dom getMojoConfiguration( MojoDescriptor mojoDescriptor )
{
- PlexusConfiguration configuration = mojoDescriptor.getConfiguration();
-
- return convert( configuration );
+ return convert( mojoDescriptor );
}
- public Xpp3Dom convert( PlexusConfiguration c )
+ public Xpp3Dom convert( MojoDescriptor mojoDescriptor )
{
- Xpp3Dom dom = new Xpp3Dom( "configuration" );
+ Map<String,Parameter> parameters = mojoDescriptor.getParameterMap();
+ Xpp3Dom dom = new Xpp3Dom( "configuration" );
+
+ PlexusConfiguration c = mojoDescriptor.getMojoConfiguration();
+
PlexusConfiguration[] ces = c.getChildren();
for( PlexusConfiguration ce : ces )
{
Xpp3Dom e = new Xpp3Dom( ce.getName() );
e.setValue( ce.getValue( ce.getAttribute( "default-value", null ) ) );
- dom.addChild( e );
+ dom.addChild( e );
}
return dom;
Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java?rev=770005&r1=770004&r2=770005&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java Wed Apr 29 23:43:08 2009
@@ -22,13 +22,12 @@
import java.util.List;
import java.util.Set;
-import org.apache.maven.BuildFailureException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin;
+import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.xml.Xpp3Dom;
@@ -47,7 +46,7 @@
* @return
* @throws LifecycleExecutionException
*/
- List<MojoDescriptor> calculateLifecyclePlan( String lifecyclePhase, MavenSession session )
+ List<MojoExecution> calculateLifecyclePlan( String lifecyclePhase, MavenSession session )
throws LifecycleExecutionException;
// For a given project packaging find all the plugins that are bound to any registered
Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=770005&r1=770004&r2=770005&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Wed Apr 29 23:43:08 2009
@@ -519,16 +519,19 @@
{
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 );
- ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session );
+ ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution );
+ // This stuff is moved to the lifecycle executor
+ //validatePomConfiguration( mojoDescriptor, pomConfiguration );
+
checkDeprecatedParameters( mojoDescriptor, pomConfiguration );
checkRequiredParameters( mojoDescriptor, pomConfiguration, expressionEvaluator );
+ //
populatePluginFields( mojo, mojoDescriptor, pomConfiguration, expressionEvaluator );
@@ -940,24 +943,6 @@
plugin.setVersion( version );
}
- /*
- public MavenProject buildPluginProject( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
- throws InvalidPluginException
- {
- Artifact artifact = repositorySystem.createProjectArtifact( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion() );
- try
- {
- MavenProject p = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories, localRepository );
-
- return p;
- }
- catch ( ProjectBuildingException e )
- {
- throw new InvalidPluginException( "Unable to build project for plugin '" + plugin.getKey() + "': " + e.getMessage(), e );
- }
- }
- */
-
public void checkRequiredMavenVersion( Plugin plugin, MavenProject pluginProject, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws PluginVersionResolutionException, InvalidPluginException
{
Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java?rev=770005&r1=770004&r2=770005&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java Wed Apr 29 23:43:08 2009
@@ -46,13 +46,12 @@
private Properties properties;
- @Deprecated
- public PluginParameterExpressionEvaluator( MavenSession session, MojoExecution mojoExecution )
+ public PluginParameterExpressionEvaluator( MavenSession session )
{
- this( session );
+ this( session, null );
}
- public PluginParameterExpressionEvaluator( MavenSession session )
+ public PluginParameterExpressionEvaluator( MavenSession session, MojoExecution mojoExecution )
{
this.session = session;
this.mojoExecution = mojoExecution;