cleanup: remove the remote repository list from the MavenMetadataSource as it was only used in retrieve(), and the equivalent list can be passed directly

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163338 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-02-08 03:26:06 +00:00
parent 32beeaed55
commit 797291178f
7 changed files with 25 additions and 54 deletions

View File

@ -2,7 +2,6 @@ package org.apache.maven.artifact.metadata;
import org.apache.maven.artifact.Artifact;
import java.io.Reader;
import java.util.Set;
/*
@ -32,6 +31,6 @@ import java.util.Set;
*/
public interface ArtifactMetadataSource
{
Set retrieve( Artifact artifact )
Set retrieve( Artifact artifact, Set remoteRepositories )
throws ArtifactMetadataRetrievalException;
}

View File

@ -2,12 +2,12 @@ package org.apache.maven.artifact.resolver;
import org.apache.maven.artifact.AbstractArtifactComponent;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
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.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.wagon.TransferFailedException;
import java.util.HashMap;
@ -227,7 +227,7 @@ public class DefaultArtifactResolver
try
{
referencedDependencies = source.retrieve( newArtifact );
referencedDependencies = source.retrieve( newArtifact, remoteRepositories );
}
catch ( ArtifactMetadataRetrievalException e )
{

View File

@ -16,19 +16,14 @@ package org.apache.maven.artifact.resolver;
* limitations under the License.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactComponentTestCase;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.codehaus.plexus.util.FileUtils;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import java.io.File;
import java.io.Writer;
import java.io.FileWriter;
import java.util.Set;
import java.util.HashSet;
import java.util.Set;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@ -142,7 +137,7 @@ public class ArtifactResolverTest
ArtifactMetadataSource mds = new ArtifactMetadataSource()
{
public Set retrieve( Artifact artifact )
public Set retrieve( Artifact artifact, Set remoteRepositories )
throws ArtifactMetadataRetrievalException
{
Set dependencies = new HashSet();
@ -190,7 +185,7 @@ public class ArtifactResolverTest
ArtifactMetadataSource mds = new ArtifactMetadataSource()
{
public Set retrieve( Artifact artifact )
public Set retrieve( Artifact artifact, Set remoteRepositories )
throws ArtifactMetadataRetrievalException
{
Set dependencies = new HashSet();

View File

@ -1,7 +1,7 @@
package org.apache.maven.artifact;
/* ====================================================================
* Copyright 2001-2004 The Apache Software Foundation.
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,13 +23,9 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.model.Dependency;
//import org.apache.maven.model.Model;
//import org.apache.maven.model.Parent;
//import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
//import java.io.FileReader;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@ -42,50 +38,39 @@ import java.util.Set;
public class MavenMetadataSource
implements ArtifactMetadataSource
{
private MavenProjectBuilder mavenProjectBuilder;
// private MavenXpp3Reader reader = new MavenXpp3Reader();
// private MavenXpp3Reader reader = new MavenXpp3Reader();
private ArtifactRepository localRepository;
private Set remoteRepositories;
private ArtifactResolver artifactResolver;
public MavenMetadataSource( Set remoteRepositories,
ArtifactRepository localRepository,
public MavenMetadataSource( ArtifactRepository localRepository,
ArtifactResolver artifactResolver,
MavenProjectBuilder projectBuilder )
{
this.localRepository = localRepository;
this.artifactResolver = artifactResolver;
this.mavenProjectBuilder = projectBuilder;
this.remoteRepositories = remoteRepositories;
}
public Set retrieve( Artifact artifact )
public Set retrieve( Artifact artifact, Set remoteRepositories )
throws ArtifactMetadataRetrievalException
{
Set artifacts;
Artifact metadataArtifact = new DefaultArtifact( artifact.getGroupId(),
artifact.getArtifactId(),
artifact.getVersion(),
"pom" );
try
{
{
artifactResolver.resolve( metadataArtifact, remoteRepositories, localRepository );
// [jdcasey/03-Feb-2005]: Replacing with ProjectBuilder, to enable
// post-processing and inheritance calculation before retrieving the
// associated artifacts. This should improve consistency.
MavenProject project = mavenProjectBuilder.build( metadataArtifact.getFile(), localRepository );
// Model model = reader.read( new FileReader( metadataArtifact.getFile() ) );
// Model model = reader.read( new FileReader( metadataArtifact.getFile() ) );
artifacts = createArtifacts( project.getDependencies(), localRepository );
}
@ -95,25 +80,21 @@ public class MavenMetadataSource
}
catch ( Exception e )
{
throw new ArtifactMetadataRetrievalException( "Cannot read artifact source: " + metadataArtifact.getFile(), e );
throw new ArtifactMetadataRetrievalException( "Cannot read artifact source: " + metadataArtifact.getFile(),
e );
}
return artifacts;
}
public Set createArtifacts( List dependencies, ArtifactRepository localRepository )
{
Set projectArtifacts = new HashSet();
for ( Iterator i = dependencies.iterator(); i.hasNext(); )
{
Dependency d = (Dependency) i.next();
Artifact artifact = createArtifact( d, localRepository );
projectArtifacts.add( artifact );
}
return projectArtifacts;
}
@ -123,8 +104,6 @@ public class MavenMetadataSource
dependency.getArtifactId(),
dependency.getVersion(),
dependency.getType() );
return artifact;
}
}

View File

@ -71,7 +71,7 @@ public class DependencyResolutionPhase
throws Exception
{
ArtifactResolver artifactResolver = null;
MavenProjectBuilder projectBuilder = null;
try
@ -79,11 +79,10 @@ public class DependencyResolutionPhase
MavenProject project = context.getProject();
artifactResolver = (ArtifactResolver) context.lookup( ArtifactResolver.ROLE );
projectBuilder = (MavenProjectBuilder) context.lookup( MavenProjectBuilder.ROLE );
MavenMetadataSource sourceReader = new MavenMetadataSource( context.getRemoteRepositories(),
context.getLocalRepository(),
MavenMetadataSource sourceReader = new MavenMetadataSource( context.getLocalRepository(),
artifactResolver,
projectBuilder );
@ -97,7 +96,7 @@ public class DependencyResolutionPhase
finally
{
context.release( artifactResolver );
context.release( projectBuilder );
}
}

View File

@ -71,7 +71,7 @@ public class DefaultPluginManager
protected Set remotePluginRepositories;
protected ArtifactFilter artifactFilter;
protected MavenProjectBuilder mavenProjectBuilder;
public DefaultPluginManager()
@ -211,11 +211,10 @@ public class DefaultPluginManager
throws Exception
{
artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE );
mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.ROLE );
MavenMetadataSource metadataSource = new MavenMetadataSource( remotePluginRepositories,
session.getLocalRepository(),
MavenMetadataSource metadataSource = new MavenMetadataSource( session.getLocalRepository(),
artifactResolver,
mavenProjectBuilder );

View File

@ -142,7 +142,7 @@ public class DefaultMavenProjectBuilder
{
Set repos = RepositoryUtils.mavenToWagon( project.getRepositories() );
MavenMetadataSource sourceReader = new MavenMetadataSource( repos, localRepository,
MavenMetadataSource sourceReader = new MavenMetadataSource( localRepository,
artifactResolver, this );
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project