o Extended repo system to grab artifacts without resolving them

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@800086 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-08-02 14:41:04 +00:00
parent 03dab5e334
commit bc744b544b
4 changed files with 68 additions and 3 deletions

View File

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

View File

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

View File

@ -260,6 +260,57 @@ public class LegacyRepositorySystem
return url; 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.resolve( request );
}
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request ) public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
{ {
/* /*

View File

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