[MNG-3819] [regression] Plugins that don't declare dependency on plexus-utils no longer get plexus-utils:1.1

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@828222 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-10-21 21:24:21 +00:00
parent bb889e5895
commit c501175f79
1 changed files with 36 additions and 0 deletions

View File

@ -458,9 +458,45 @@ public class DefaultMavenPluginManager
List<Artifact> pluginArtifacts = new ArrayList<Artifact>( result.getArtifacts() );
addPlexusUtils( pluginArtifacts, plugin, repositoryRequest );
return pluginArtifacts;
}
// backward-compatibility with Maven 2.x
private void addPlexusUtils( List<Artifact> pluginArtifacts, Plugin plugin, RepositoryRequest repositoryRequest )
throws PluginResolutionException
{
for ( Artifact artifact : pluginArtifacts )
{
if ( "org.codehaus.plexus:plexus-utils:jar".equals( artifact.getDependencyConflictId() ) )
{
return;
}
}
Artifact plexusUtils =
repositorySystem.createArtifact( "org.codehaus.plexus", "plexus-utils", "1.1", Artifact.SCOPE_RUNTIME,
"jar" );
ArtifactResolutionRequest request = new ArtifactResolutionRequest( repositoryRequest );
request.setArtifact( plexusUtils );
request.setResolveRoot( true );
request.setResolveTransitively( false );
ArtifactResolutionResult result = repositorySystem.resolve( request );
try
{
resolutionErrorHandler.throwErrors( request, result );
}
catch ( ArtifactResolutionException e )
{
throw new PluginResolutionException( plugin, e );
}
pluginArtifacts.add( plexusUtils );
}
public <T> T getConfiguredMojo( Class<T> mojoInterface, MavenSession session, MojoExecution mojoExecution )
throws PluginConfigurationException, PluginContainerException
{