o taking more legacy artifact components out of the plugin manager

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@746336 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-02-20 18:52:57 +00:00
parent f6d25b36f8
commit db63dc78c0
3 changed files with 49 additions and 14 deletions

View File

@ -19,11 +19,13 @@ package org.apache.maven.plugin.version;
* under the License.
*/
import java.util.Iterator;
import java.util.List;
import org.apache.maven.MavenTools;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.metadata.ResolutionGroup;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.versioning.ArtifactVersion;
@ -43,20 +45,14 @@ import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.StringUtils;
import java.util.Iterator;
import java.util.List;
@Component(role = PluginVersionManager.class)
public class DefaultPluginVersionManager
extends AbstractLogEnabled
implements PluginVersionManager
{
@Requirement
private ArtifactFactory artifactFactory;
@Requirement
private ArtifactMetadataSource artifactMetadataSource;
private MavenTools repositoryTools;
@Requirement
private MavenProjectBuilder mavenProjectBuilder;
@ -188,7 +184,7 @@ public class DefaultPluginVersionManager
{
getLogger().info( "Attempting to resolve a version for plugin: " + groupId + ":" + artifactId + " using meta-version: " + metaVersionId );
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
Artifact artifact = repositoryTools.createProjectArtifact( groupId, artifactId, metaVersionId );
String key = artifact.getDependencyConflictId();
@ -198,7 +194,7 @@ public class DefaultPluginVersionManager
try
{
ResolutionGroup resolutionGroup =
artifactMetadataSource.retrieve( artifact, localRepository, project.getRemoteArtifactRepositories() );
repositoryTools.retrieve( artifact, localRepository, project.getRemoteArtifactRepositories() );
// switching this out with the actual resolved artifact instance, since the MMSource re-creates the pom
// artifact.
@ -222,7 +218,7 @@ public class DefaultPluginVersionManager
MavenProject pluginProject;
try
{
artifact = artifactFactory.createProjectArtifact( groupId, artifactId, artifactVersion );
artifact = repositoryTools.createProjectArtifact( groupId, artifactId, artifactVersion );
pluginProject = mavenProjectBuilder.buildFromRepository( artifact, project.getRemoteArtifactRepositories(), localRepository );
}
@ -283,7 +279,7 @@ public class DefaultPluginVersionManager
getLogger().debug( "Trying " + vr );
try
{
List versions = artifactMetadataSource.retrieveAvailableVersions( artifact, localRepository,
List versions = repositoryTools.retrieveAvailableVersions( artifact, localRepository,
project.getRemoteArtifactRepositories() );
ArtifactVersion v = vr.matchVersion( versions );
artifactVersion = v != null ? v.toString() : null;

View File

@ -36,6 +36,9 @@ import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.metadata.ResolutionGroup;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
@ -44,6 +47,7 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.model.Model;
import org.apache.maven.model.Repository;
@ -81,6 +85,9 @@ public class DefaultMavenTools
@Requirement
private WagonManager wagonManager;
@Requirement
private ArtifactMetadataSource artifactMetadataSource;
@Requirement
private Logger logger;
@ -98,6 +105,25 @@ public class DefaultMavenTools
return artifactFactory.createArtifactWithClassifier(groupId, artifactId, version, type, classifier);
}
public Artifact createProjectArtifact( String groupId, String artifactId, String metaVersionId )
{
return artifactFactory.createProjectArtifact(groupId, artifactId, metaVersionId );
}
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
{
return artifactMetadataSource.retrieve(artifact, localRepository, remoteRepositories);
}
// ----------------------------------------------------------------------------
// Code snagged from ProjectUtils: this will have to be moved somewhere else
// but just trying to collect it all in one place right now.

View File

@ -24,15 +24,20 @@ import java.util.List;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ResolutionGroup;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.model.Model;
import org.apache.maven.model.Repository;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.wagon.events.TransferListener;
import org.codehaus.plexus.component.annotations.Requirement;
/**
* @author Jason van Zyl
@ -76,6 +81,14 @@ public interface MavenTools
Artifact createArtifactWithClassifier(String groupId, String artifactId, String version, String type, String classifier);
Artifact createProjectArtifact( String groupId, String artifactId, String metaVersionId );
List<ArtifactVersion> retrieveAvailableVersions(Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories)
throws ArtifactMetadataRetrievalException;
ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException;
// WagonManager
ArtifactRepository getMirrorRepository( ArtifactRepository repository );