o remove legacy artifact component references from the embedder

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@746311 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-02-20 18:03:46 +00:00
parent dd676fd685
commit f6d25b36f8
4 changed files with 30 additions and 44 deletions

View File

@ -31,14 +31,11 @@ import java.util.Iterator;
import java.util.List;
import org.apache.maven.Maven;
import org.apache.maven.MavenTools;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.repository.ArtifactRepository;
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.embedder.execution.MavenExecutionRequestPopulator;
import org.apache.maven.errors.CoreErrorReporter;
import org.apache.maven.errors.CoreReporterManager;
@ -140,12 +137,8 @@ public class MavenEmbedder
private MavenXpp3Writer modelWriter;
private ArtifactFactory artifactFactory;
private ArtifactResolver artifactResolver;
private ArtifactHandlerManager artifactHandlerManager;
private MavenTools repositoryTools;
private Maven maven;
private MavenExecutionRequestPopulator populator;
@ -474,7 +467,7 @@ public class MavenEmbedder
String scope,
String type )
{
return artifactFactory.createArtifact( groupId, artifactId, version, scope, type );
return repositoryTools.createArtifact( groupId, artifactId, version, scope, type );
}
public Artifact createArtifactWithClassifier( String groupId,
@ -483,7 +476,7 @@ public class MavenEmbedder
String type,
String classifier )
{
return artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
return repositoryTools.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
}
public void resolve( Artifact artifact,
@ -491,12 +484,7 @@ public class MavenEmbedder
ArtifactRepository localRepository )
throws ArtifactResolutionException, ArtifactNotFoundException
{
artifactResolver.resolve( artifact, remoteRepositories, localRepository );
}
public ArtifactHandler getArtifactHandler( Artifact artifact )
{
return artifactHandlerManager.getArtifactHandler( artifact.getType() );
repositoryTools.resolve( artifact, localRepository, remoteRepositories );
}
// ----------------------------------------------------------------------
@ -665,22 +653,14 @@ public class MavenEmbedder
mavenProjectBuilder = container.lookup( MavenProjectBuilder.class );
// ----------------------------------------------------------------------
// Artifact related components
// ----------------------------------------------------------------------
artifactFactory = container.lookup( ArtifactFactory.class );
artifactResolver = container.lookup( ArtifactResolver.class );
populator = container.lookup( MavenExecutionRequestPopulator.class );
buildPlanner = container.lookup( BuildPlanner.class );
artifactHandlerManager = container.lookup( ArtifactHandlerManager.class );
pluginRepository = container.lookup( PluginRepository.class );
repositoryTools = container.lookup( MavenTools.class );
// This is temporary as we can probably cache a single request and use it for default values and
// simply cascade values in from requests used for individual executions.
request = new DefaultMavenExecutionRequest();

View File

@ -86,6 +86,18 @@ public class DefaultMavenTools
private static HashMap<String, Artifact> cache = new HashMap<String, Artifact>();
// Artifact Creation
public Artifact createArtifact(String groupId, String artifactId, String version, String scope, String type)
{
return artifactFactory.createArtifact(groupId, artifactId, version, scope, type);
}
public Artifact createArtifactWithClassifier(String groupId, String artifactId, String version, String type, String classifier)
{
return artifactFactory.createArtifactWithClassifier(groupId, artifactId, version, type, classifier);
}
// ----------------------------------------------------------------------------
// Code snagged from ProjectUtils: this will have to be moved somewhere else
// but just trying to collect it all in one place right now.
@ -391,23 +403,11 @@ public class DefaultMavenTools
* @throws IOException if there is a problem resolving the artifact
*/
public void resolve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws IOException
throws ArtifactResolutionException, ArtifactNotFoundException
{
File artifactFile = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
artifact.setFile( artifactFile );
try
{
artifactResolver.resolve( artifact, remoteRepositories, localRepository );
}
catch ( ArtifactResolutionException e )
{
throw new IOException( e.getMessage() );
}
catch ( ArtifactNotFoundException e )
{
throw new IOException( e.getMessage() );
}
artifactResolver.resolve( artifact, remoteRepositories, localRepository );
}
// ------------------------------------------------------------------------

View File

@ -26,6 +26,8 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.InvalidRepositoryException;
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.model.DeploymentRepository;
import org.apache.maven.model.Model;
import org.apache.maven.model.Repository;
@ -68,8 +70,12 @@ public interface MavenTools
// PomArtifactResolver
void resolve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws IOException;
throws ArtifactResolutionException, ArtifactNotFoundException;
Artifact createArtifact(String groupId, String artifactId, String version, String scope, String type);
Artifact createArtifactWithClassifier(String groupId, String artifactId, String version, String type, String classifier);
// WagonManager
ArtifactRepository getMirrorRepository( ArtifactRepository repository );

View File

@ -59,7 +59,7 @@ under the License.
<mercuryMp3Version>1.0-alpha-1</mercuryMp3Version>
<securityDispatcherVersion>1.0</securityDispatcherVersion>
<woodstoxVersion>3.2.6</woodstoxVersion>
<modelloVersion>1.0</modelloVersion>
<modelloVersion>1.0.1-SNAPSHOT</modelloVersion>
<jxpathVersion>1.3</jxpathVersion>
</properties>
<issueManagement>