o Simplified code

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@809532 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-08-31 10:41:55 +00:00
parent 6d604c17c7
commit 3f6ba89be7
5 changed files with 8 additions and 94 deletions

View File

@ -35,7 +35,6 @@ import org.apache.maven.wagon.events.TransferListener;
// Just hide the one method we want behind the RepositorySystem interface.
public interface ArtifactResolver
{
ArtifactResolutionResult collect( ArtifactResolutionRequest request );
ArtifactResolutionResult resolve( ArtifactResolutionRequest request );

View File

@ -363,17 +363,7 @@ public class DefaultArtifactResolver
//
// ------------------------------------------------------------------------
public ArtifactResolutionResult collect( ArtifactResolutionRequest request )
{
return resolve( request, true );
}
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
{
return resolve( request, false );
}
private ArtifactResolutionResult resolve( ArtifactResolutionRequest request, boolean collectOnly )
{
Artifact rootArtifact = request.getArtifact();
Set<Artifact> artifacts = request.getArtifactDependencies();
@ -414,7 +404,7 @@ public class DefaultArtifactResolver
// file reference. But this may be a Maven Plugin that we need to resolve from a remote repository
// as well as its dependencies.
if ( !collectOnly && request.isResolveRoot() /* && rootArtifact.getFile() == null */ )
if ( request.isResolveRoot() /* && rootArtifact.getFile() == null */ )
{
try
{
@ -503,7 +493,7 @@ public class DefaultArtifactResolver
return result;
}
if ( !collectOnly && result.getArtifacts() != null )
if ( result.getArtifacts() != null )
{
for ( Artifact artifact : result.getArtifacts() )
{

View File

@ -261,57 +261,6 @@ public class LegacyRepositorySystem
return url;
}
public ArtifactResolutionResult collect( ArtifactResolutionRequest request )
{
/*
* Probably is not worth it, but here I make sure I restore request
* to its original state.
*/
try
{
LocalArtifactRepository ideWorkspace = plexus.lookup( LocalArtifactRepository.class, LocalArtifactRepository.IDE_WORKSPACE );
if ( request.getLocalRepository() instanceof DelegatingLocalArtifactRepository )
{
DelegatingLocalArtifactRepository delegatingLocalRepository = (DelegatingLocalArtifactRepository) request.getLocalRepository();
LocalArtifactRepository orig = delegatingLocalRepository.getIdeWorspace();
delegatingLocalRepository.setIdeWorkspace( ideWorkspace );
try
{
return artifactResolver.collect( request );
}
finally
{
delegatingLocalRepository.setIdeWorkspace( orig );
}
}
else
{
ArtifactRepository localRepository = request.getLocalRepository();
DelegatingLocalArtifactRepository delegatingLocalRepository = new DelegatingLocalArtifactRepository( localRepository );
delegatingLocalRepository.setIdeWorkspace( ideWorkspace );
request.setLocalRepository( delegatingLocalRepository );
try
{
return artifactResolver.collect( request );
}
finally
{
request.setLocalRepository( localRepository );
}
}
}
catch ( ComponentLookupException e )
{
// no ide workspace artifact resolution
}
return artifactResolver.collect( request );
}
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
{
/*

View File

@ -90,8 +90,6 @@ public interface RepositorySystem
*/
List<ArtifactRepository> getEffectiveRepositories( List<ArtifactRepository> repositories );
ArtifactResolutionResult collect( ArtifactResolutionRequest request );
ArtifactResolutionResult resolve( ArtifactResolutionRequest request );
MetadataResolutionResult resolveMetadata( MetadataResolutionRequest request );

View File

@ -392,16 +392,19 @@ public class DefaultMavenPluginManager
overrideArtifacts.add( repositorySystem.createDependencyArtifact( dependency ) );
}
ArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM );
ArtifactFilter collectionFilter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM );
ArtifactFilter resolutionFilter = artifactFilterManager.getCoreArtifactFilter();
ArtifactResolutionRequest request = new ArtifactResolutionRequest( repositoryRequest );
request.setArtifact( pluginArtifact );
request.setArtifactDependencies( overrideArtifacts );
request.setCollectionFilter( filter );
request.setCollectionFilter( collectionFilter );
request.setResolutionFilter( resolutionFilter );
request.setResolveRoot( true );
request.setResolveTransitively( true );
ArtifactResolutionResult result = repositorySystem.collect( request );
ArtifactResolutionResult result = repositorySystem.resolve( request );
try
{
resolutionErrorHandler.throwErrors( request, result );
@ -413,31 +416,6 @@ public class DefaultMavenPluginManager
List<Artifact> pluginArtifacts = new ArrayList<Artifact>( result.getArtifacts() );
request.setResolveRoot( true ).setResolveTransitively( false ).setArtifactDependencies( null );
filter = artifactFilterManager.getCoreArtifactFilter();
for ( Artifact artifact : pluginArtifacts )
{
if ( filter.include( artifact ) )
{
result = repositorySystem.resolve( request.setArtifact( artifact ) );
try
{
resolutionErrorHandler.throwErrors( request, result );
}
catch ( ArtifactResolutionException e )
{
throw new PluginResolutionException( plugin, e );
}
}
else
{
artifact.setFile( null );
artifact.setResolved( false );
}
}
return pluginArtifacts;
}