mirror of https://github.com/apache/maven.git
o nuke another big chunk of the old code, looking for available versions is used internally and once all the methods are shed we'll supply a pure metadata resolution for clients, like IDEs, that need to nicely show versions. we'll also provide a graph too so people aren't going to have to do all the extra crap to get decent information.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@751036 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c586c81065
commit
5678f17198
|
@ -39,8 +39,10 @@ import org.apache.maven.artifact.transform.ArtifactTransformationManager;
|
|||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||
import org.apache.maven.wagon.TransferFailedException;
|
||||
import org.apache.maven.wagon.events.TransferListener;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
|
@ -76,6 +78,12 @@ public class DefaultArtifactResolver
|
|||
@Requirement
|
||||
private ResolutionErrorHandler resolutionErrorHandler;
|
||||
|
||||
@Requirement
|
||||
private PlexusContainer container;
|
||||
|
||||
//@Requirement
|
||||
private ArtifactMetadataSource metadataSource;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Implementation
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -350,6 +358,18 @@ public class DefaultArtifactResolver
|
|||
List<ResolutionListener> listeners = request.getListeners();
|
||||
ArtifactFilter filter = request.getFilter();
|
||||
|
||||
if ( source == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
source = container.lookup( ArtifactMetadataSource.class );
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
// Won't happen
|
||||
}
|
||||
}
|
||||
|
||||
if ( listeners == null )
|
||||
{
|
||||
listeners = new ArrayList<ResolutionListener>();
|
||||
|
|
|
@ -404,8 +404,13 @@ public class DefaultPluginManager
|
|||
// followed by the plugin's default artifact set
|
||||
dependencies.addAll( resolutionGroup.getArtifacts() );
|
||||
|
||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest().setArtifact( pluginArtifact ).setArtifactDependencies( dependencies ).setLocalRepository( localRepository )
|
||||
.setRemoteRepostories( project.getRemoteArtifactRepositories() ).setManagedVersionMap( pluginManagedDependencies ).setFilter( filter ).setMetadataSource( repositorySystem );
|
||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
|
||||
.setArtifact( pluginArtifact )
|
||||
.setArtifactDependencies( dependencies )
|
||||
.setLocalRepository( localRepository )
|
||||
.setRemoteRepostories( project.getRemoteArtifactRepositories() )
|
||||
.setManagedVersionMap( pluginManagedDependencies )
|
||||
.setFilter( filter );
|
||||
|
||||
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
||||
resolutionErrorHandler.throwErrors( request, result );
|
||||
|
@ -1348,8 +1353,10 @@ public class DefaultPluginManager
|
|||
ArtifactFilter filter = new ScopeArtifactFilter( scope );
|
||||
|
||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest().setArtifact( artifact ).setResolveRoot( false ).setArtifactDependencies( project.getDependencyArtifacts() )
|
||||
.setLocalRepository( context.getLocalRepository() ).setRemoteRepostories( project.getRemoteArtifactRepositories() ).setManagedVersionMap( project.getManagedVersionMap() )
|
||||
.setFilter( filter ).setMetadataSource( repositorySystem );
|
||||
.setLocalRepository( context.getLocalRepository() )
|
||||
.setRemoteRepostories( project.getRemoteArtifactRepositories() )
|
||||
.setManagedVersionMap( project.getManagedVersionMap() )
|
||||
.setFilter( filter );
|
||||
|
||||
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
||||
|
||||
|
|
|
@ -260,8 +260,7 @@ public class DefaultMavenProjectBuilder
|
|||
ArtifactResolutionRequest request = new ArtifactResolutionRequest().setArtifact( pomArtifact ).setArtifactDependencies( project.getDependencyArtifacts() )
|
||||
.setLocalRepository( configuration.getLocalRepository() )
|
||||
.setRemoteRepostories( project.getRemoteArtifactRepositories() )
|
||||
.setManagedVersionMap( project.getManagedVersionMap() )
|
||||
.setMetadataSource( repositorySystem );
|
||||
.setManagedVersionMap( project.getManagedVersionMap() );
|
||||
|
||||
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
||||
|
||||
|
|
|
@ -388,65 +388,6 @@ public class MavenMetadataSource
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private List aggregateRepositoryLists( List remoteRepositories, List remoteArtifactRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
if ( superProject == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
superProject = mavenProjectBuilder.buildStandaloneSuperProject( new DefaultProjectBuilderConfiguration() );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException(
|
||||
"Unable to parse the Maven built-in model: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
List repositories = new ArrayList();
|
||||
|
||||
repositories.addAll( remoteRepositories );
|
||||
|
||||
// ensure that these are defined
|
||||
for ( Iterator it = superProject.getRemoteArtifactRepositories().iterator(); it.hasNext(); )
|
||||
{
|
||||
ArtifactRepository superRepo = (ArtifactRepository) it.next();
|
||||
|
||||
for ( Iterator aggregatedIterator = repositories.iterator(); aggregatedIterator.hasNext(); )
|
||||
{
|
||||
ArtifactRepository repo = (ArtifactRepository) aggregatedIterator.next();
|
||||
|
||||
// if the repository exists in the list and was introduced by another POM's super-pom,
|
||||
// remove it...the repository definitions from the super-POM should only be at the end of
|
||||
// the list.
|
||||
// if the repository has been redefined, leave it.
|
||||
if ( repo.getId().equals( superRepo.getId() ) && repo.getUrl().equals( superRepo.getUrl() ) )
|
||||
{
|
||||
aggregatedIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( remoteArtifactRepositories != null )
|
||||
{
|
||||
// this list should contain the super-POM repositories, so we don't have to explicitly add them back.
|
||||
for ( Iterator it = remoteArtifactRepositories.iterator(); it.hasNext(); )
|
||||
{
|
||||
ArtifactRepository repository = (ArtifactRepository) it.next();
|
||||
|
||||
if ( !repositories.contains( repository ) )
|
||||
{
|
||||
repositories.add( repository );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return repositories;
|
||||
}
|
||||
*/
|
||||
|
||||
public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
|
|
|
@ -277,12 +277,6 @@ public class LegacyMavenRepositorySystem
|
|||
return projectArtifacts;
|
||||
}
|
||||
|
||||
public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
return artifactMetadataSource.retrieveAvailableVersions( artifact, localRepository, remoteRepositories );
|
||||
}
|
||||
|
||||
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
|
@ -468,15 +462,6 @@ public class LegacyMavenRepositorySystem
|
|||
}
|
||||
}
|
||||
|
||||
// These two methods are here so that the ArtifactMetadataSource is implemented so that I can pass this into an ArtifactResolutionRequest.
|
||||
// Intermediate measure before separating the RepositorySystem out into its own module.
|
||||
|
||||
public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
return artifactMetadataSource.retrieveAvailableVersionsFromDeploymentRepository( artifact, localRepository, remoteRepository );
|
||||
}
|
||||
|
||||
public Artifact retrieveRelocatedArtifact( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.apache.maven.wagon.events.TransferListener;
|
|||
* @author Jason van Zyl
|
||||
*/
|
||||
public interface MavenRepositorySystem
|
||||
extends ArtifactMetadataSource // This needs to be removed and it's here because it's passed into the resolver. not sure why we didn't just inject the metadata source.
|
||||
{
|
||||
// Artifact creation: This needs to be reduced to fewer, if not one, method.
|
||||
|
||||
|
@ -80,16 +79,7 @@ public interface MavenRepositorySystem
|
|||
//MetadataResolutionResult resolveMetadata( MetadataResolutionRequest request );
|
||||
|
||||
ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException;
|
||||
|
||||
// Retrieving available versions is a function of what repositories that you pass in. If you want local and remote versions then you pass
|
||||
// in both those repositories. We don't need two methods here.
|
||||
List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException;
|
||||
|
||||
// These are only showing up in tests, not called from anywhere else in the core
|
||||
public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository )
|
||||
throws ArtifactMetadataRetrievalException;
|
||||
throws ArtifactMetadataRetrievalException;
|
||||
|
||||
// Relocated artifacts are stupid. If you you want to move your shit then too bad. You have to support all your users and leave your stuff
|
||||
// there. This is just so problematic because it makes Maven folk responsible and makes the system complicated.
|
||||
|
|
Loading…
Reference in New Issue