o Fixed propagation of project-level plugin dependencies by directly associating the mojo execution with the originating plugin instance. The key difference between a plugin instance and the g🅰️v triplet are the dependencies in the plugin instance which can't be easily reconstructed from just the g🅰️v but are crucial for construction of the plugin realm.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@782377 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-06-07 12:16:46 +00:00
parent d07123e796
commit 76e9387f5d
3 changed files with 30 additions and 20 deletions

View File

@ -313,7 +313,11 @@ public class DefaultLifecycleExecutor
//TODO: remove hard coding //TODO: remove hard coding
if ( phase.equals( "clean" ) ) if ( phase.equals( "clean" ) )
{ {
mojos.add( new MojoExecution( "org.apache.maven.plugins", "maven-clean-plugin", "2.3", "clean", "default-clean" ) ); Plugin plugin = new Plugin();
plugin.setGroupId( "org.apache.maven.plugins" );
plugin.setArtifactId( "maven-clean-plugin" );
plugin.setVersion( "2.3" );
mojos.add( new MojoExecution( plugin, "clean", "default-clean" ) );
} }
// This is just just laying out the initial structure of the mojos to run in each phase of the // This is just just laying out the initial structure of the mojos to run in each phase of the
@ -347,7 +351,7 @@ public class DefaultLifecycleExecutor
phaseToMojoMapping.put( execution.getPhase(), new ArrayList<MojoExecution>() ); phaseToMojoMapping.put( execution.getPhase(), new ArrayList<MojoExecution>() );
} }
MojoExecution mojoExecution = new MojoExecution( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), goal, execution.getId() ); MojoExecution mojoExecution = new MojoExecution( plugin, goal, execution.getId() );
phaseToMojoMapping.get( execution.getPhase() ).add( mojoExecution ); phaseToMojoMapping.get( execution.getPhase() ).add( mojoExecution );
} }
} }
@ -360,7 +364,7 @@ public class DefaultLifecycleExecutor
if ( mojoDescriptor.getPhase() != null && phaseToMojoMapping.get( mojoDescriptor.getPhase() ) != null ) if ( mojoDescriptor.getPhase() != null && phaseToMojoMapping.get( mojoDescriptor.getPhase() ) != null )
{ {
MojoExecution mojoExecution = new MojoExecution( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), goal, execution.getId() ); MojoExecution mojoExecution = new MojoExecution( plugin, goal, execution.getId() );
phaseToMojoMapping.get( mojoDescriptor.getPhase() ).add( mojoExecution ); phaseToMojoMapping.get( mojoDescriptor.getPhase() ).add( mojoExecution );
} }
} }
@ -395,7 +399,7 @@ public class DefaultLifecycleExecutor
// org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process // org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process
// //
MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor(
mojoExecution.getGroupId(), mojoExecution.getArtifactId(), mojoExecution.getVersion(), mojoExecution.getGoal(), session.getLocalRepository(), project.getPluginArtifactRepositories() ); mojoExecution.getPlugin(), mojoExecution.getGoal(), session.getLocalRepository(), project.getPluginArtifactRepositories() );
requiredDependencyResolutionScope = calculateRequiredDependencyResolutionScope( requiredDependencyResolutionScope, mojoDescriptor.isDependencyResolutionRequired() ); requiredDependencyResolutionScope = calculateRequiredDependencyResolutionScope( requiredDependencyResolutionScope, mojoDescriptor.isDependencyResolutionRequired() );
@ -794,7 +798,7 @@ public class DefaultLifecycleExecutor
{ {
for( String goal : pluginExecution.getGoals() ) for( String goal : pluginExecution.getGoals() )
{ {
Xpp3Dom dom = getDefaultPluginConfiguration( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), goal, localRepository, remoteRepositories ); Xpp3Dom dom = getDefaultPluginConfiguration( plugin, goal, localRepository, remoteRepositories );
pluginExecution.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) pluginExecution.getConfiguration(), dom, Boolean.TRUE ) ); pluginExecution.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) pluginExecution.getConfiguration(), dom, Boolean.TRUE ) );
} }
} }
@ -809,14 +813,14 @@ public class DefaultLifecycleExecutor
} }
} }
private Xpp3Dom getDefaultPluginConfiguration( String groupId, String artifactId, String version, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories ) private Xpp3Dom getDefaultPluginConfiguration( Plugin plugin, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws LifecycleExecutionException throws LifecycleExecutionException
{ {
MojoDescriptor mojoDescriptor; MojoDescriptor mojoDescriptor;
try try
{ {
mojoDescriptor = pluginManager.getMojoDescriptor( groupId, artifactId, version, goal, localRepository, remoteRepositories ); mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, localRepository, remoteRepositories );
} }
catch ( PluginNotFoundException e ) catch ( PluginNotFoundException e )
{ {

View File

@ -274,7 +274,7 @@ public class DefaultPluginManager
// defined dependencies and then the result is merged with the overrides. The overrides don't pass through the metadata source which is where the // defined dependencies and then the result is merged with the overrides. The overrides don't pass through the metadata source which is where the
// Artifact.setFile( file ) method is called. We should eventually take care of this in the resolver. // Artifact.setFile( file ) method is called. We should eventually take care of this in the resolver.
Artifact a = repositorySystem.createDependencyArtifact( dependencySpecifiedInProject ); Artifact a = repositorySystem.createDependencyArtifact( dependencySpecifiedInProject );
if ( a.getScope().equals( Artifact.SCOPE_SYSTEM ) ) if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) )
{ {
a.setFile( new File( dependencySpecifiedInProject.getSystemPath() ) ); a.setFile( new File( dependencySpecifiedInProject.getSystemPath() ) );
} }

View File

@ -19,16 +19,14 @@ package org.apache.maven.plugin;
* under the License. * under the License.
*/ */
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3Dom;
public class MojoExecution public class MojoExecution
{ {
private String groupId;
private String artifactId; private Plugin plugin;
private String version;
private String goal; private String goal;
@ -44,11 +42,9 @@ public class MojoExecution
*/ */
private String lifecyclePhase; private String lifecyclePhase;
public MojoExecution( String groupId, String artifactId, String version, String goal, String executionId ) public MojoExecution( Plugin plugin, String goal, String executionId )
{ {
this.groupId = groupId; this.plugin = plugin;
this.artifactId = artifactId;
this.version = version;
this.goal = goal; this.goal = goal;
this.executionId = executionId; this.executionId = executionId;
} }
@ -79,6 +75,16 @@ public class MojoExecution
return executionId; return executionId;
} }
public Plugin getPlugin()
{
if ( mojoDescriptor != null )
{
return mojoDescriptor.getPluginDescriptor().getPlugin();
}
return plugin;
}
public MojoDescriptor getMojoDescriptor() public MojoDescriptor getMojoDescriptor()
{ {
return mojoDescriptor; return mojoDescriptor;
@ -133,7 +139,7 @@ public class MojoExecution
return mojoDescriptor.getPluginDescriptor().getGroupId(); return mojoDescriptor.getPluginDescriptor().getGroupId();
} }
return groupId; return plugin.getGroupId();
} }
public String getArtifactId() public String getArtifactId()
@ -143,7 +149,7 @@ public class MojoExecution
return mojoDescriptor.getPluginDescriptor().getArtifactId(); return mojoDescriptor.getPluginDescriptor().getArtifactId();
} }
return artifactId; return plugin.getArtifactId();
} }
public String getVersion() public String getVersion()
@ -153,7 +159,7 @@ public class MojoExecution
return mojoDescriptor.getPluginDescriptor().getVersion(); return mojoDescriptor.getPluginDescriptor().getVersion();
} }
return version; return plugin.getVersion();
} }
public String getGoal() public String getGoal()