From 3f6ba89be7bd63095f958b7ec6c4c86406465287 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Mon, 31 Aug 2009 10:41:55 +0000 Subject: [PATCH] o Simplified code git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@809532 13f79535-47bb-0310-9956-ffa450edef68 --- .../artifact/resolver/ArtifactResolver.java | 1 - .../resolver/DefaultArtifactResolver.java | 14 +---- .../repository/LegacyRepositorySystem.java | 51 ------------------- .../maven/repository/RepositorySystem.java | 2 - .../internal/DefaultMavenPluginManager.java | 34 +++---------- 5 files changed, 8 insertions(+), 94 deletions(-) diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java index 85486f7354..25af479521 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java @@ -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 ); diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java index ee9cf707d5..6289d8d6e9 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java @@ -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 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() ) { diff --git a/maven-compat/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java b/maven-compat/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java index d3b14dfa00..48ad0bfff6 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java @@ -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 ) { /* diff --git a/maven-compat/src/main/java/org/apache/maven/repository/RepositorySystem.java b/maven-compat/src/main/java/org/apache/maven/repository/RepositorySystem.java index 50487da7e3..0be35168c4 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/RepositorySystem.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/RepositorySystem.java @@ -90,8 +90,6 @@ public interface RepositorySystem */ List getEffectiveRepositories( List repositories ); - ArtifactResolutionResult collect( ArtifactResolutionRequest request ); - ArtifactResolutionResult resolve( ArtifactResolutionRequest request ); MetadataResolutionResult resolveMetadata( MetadataResolutionRequest request ); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java index 146be9b836..0aeb2bd464 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java @@ -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 pluginArtifacts = new ArrayList( 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; }