o use the repositories passed into the request

o make sure that mirrors are processed correctly in that the mirror that is defined must use the layout and policies of the repository it is mirroring


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@750251 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-03-05 00:15:56 +00:00
parent 3b4dd11674
commit 1a05bdac38
14 changed files with 81 additions and 45 deletions

View File

@ -35,8 +35,7 @@ public interface ArtifactRepository
String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata );
String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata,
ArtifactRepository repository );
String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository );
String getUrl();
@ -47,11 +46,14 @@ public interface ArtifactRepository
String getId();
ArtifactRepositoryPolicy getSnapshots();
void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy policy );
ArtifactRepositoryPolicy getReleases();
void setReleaseUpdatePolicy( ArtifactRepositoryPolicy policy );
ArtifactRepositoryLayout getLayout();
void setLayout( ArtifactRepositoryLayout layout );
String getKey();
boolean isUniqueVersion();

View File

@ -52,9 +52,7 @@ public class DefaultArtifactRepository
* @param url the URL of the repository
* @param layout the layout of the repository
*/
public DefaultArtifactRepository( String id,
String url,
ArtifactRepositoryLayout layout )
public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout )
{
this( id, url, layout, null, null );
}
@ -67,10 +65,7 @@ public class DefaultArtifactRepository
* @param layout the layout of the repository
* @param uniqueVersion whether to assign each snapshot a unique version
*/
public DefaultArtifactRepository( String id,
String url,
ArtifactRepositoryLayout layout,
boolean uniqueVersion )
public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, boolean uniqueVersion )
{
super( id, url );
this.layout = layout;
@ -86,11 +81,7 @@ public class DefaultArtifactRepository
* @param snapshots the policies to use for snapshots
* @param releases the policies to use for releases
*/
public DefaultArtifactRepository( String id,
String url,
ArtifactRepositoryLayout layout,
ArtifactRepositoryPolicy snapshots,
ArtifactRepositoryPolicy releases )
public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases )
{
super( id, url );
@ -129,17 +120,27 @@ public class DefaultArtifactRepository
return layout.pathOfLocalRepositoryMetadata( metadata, repository );
}
public void setLayout( ArtifactRepositoryLayout layout )
{
this.layout = layout;
}
public ArtifactRepositoryLayout getLayout()
{
return layout;
}
public void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy snapshots )
{
this.snapshots = snapshots;
}
public ArtifactRepositoryPolicy getSnapshots()
{
return snapshots;
}
public void setReleases( ArtifactRepositoryPolicy releases )
public void setReleaseUpdatePolicy( ArtifactRepositoryPolicy releases )
{
this.releases = releases;
}
@ -168,4 +169,17 @@ public class DefaultArtifactRepository
{
this.blacklisted = blacklisted;
}
public String toString()
{
StringBuffer sb = new StringBuffer();
sb.append( " id: " + getId() ).append( "\n" );
sb.append( " url: " + getUrl() ).append( "\n" );
sb.append( " layout: " + layout.getId() ).append( "\n" );
sb.append( "snapshot policy: [update => " + snapshots.getUpdatePolicy() ).append( " ]\n" );
sb.append( " release policy: [update => " + releases.getUpdatePolicy() ).append( " ]\n" );
return sb.toString();
}
}

View File

@ -28,10 +28,11 @@ public interface ArtifactRepositoryLayout
{
String ROLE = ArtifactRepositoryLayout.class.getName();
String getId();
String pathOf( Artifact artifact );
String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata,
ArtifactRepository repository );
String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository );
String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata );
}

View File

@ -38,6 +38,11 @@ public class DefaultRepositoryLayout
private static final char ARTIFACT_SEPARATOR = '-';
public String getId()
{
return "default";
}
public String pathOf( Artifact artifact )
{
ArtifactHandler artifactHandler = artifact.getArtifactHandler();

View File

@ -20,6 +20,11 @@ public class FlatRepositoryLayout
private static final char GROUP_SEPARATOR = '.';
public String getId()
{
return "flat";
}
public String pathOf( Artifact artifact )
{
ArtifactHandler artifactHandler = artifact.getArtifactHandler();

View File

@ -34,6 +34,11 @@ public class LegacyRepositoryLayout
{
private static final String PATH_SEPARATOR = "/";
public String getId()
{
return "legacy";
}
public String pathOf( Artifact artifact )
{
ArtifactHandler artifactHandler = artifact.getArtifactHandler();

View File

@ -487,6 +487,11 @@ public class DefaultWagonManagerTest
private final class ArtifactRepositoryLayoutStub
implements ArtifactRepositoryLayout
{
public String getId()
{
return "test";
}
public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata )
{
return "path";

View File

@ -127,8 +127,7 @@ public class DefaultPluginManagerSupport
}
catch ( ProjectBuildingException e )
{
throw new InvalidPluginException( "Unable to build project for plugin '"
+ plugin.getKey() + "': " + e.getMessage(), e );
throw new InvalidPluginException( "Unable to build project for plugin '" + plugin.getKey() + "': " + e.getMessage(), e );
}
}

View File

@ -17,7 +17,6 @@ import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
/**
@ -29,11 +28,12 @@ import org.codehaus.plexus.logging.Logger;
*/
@Component(role = PluginLoader.class)
public class DefaultPluginLoader
implements PluginLoader, LogEnabled
implements PluginLoader
{
@Requirement
private PluginManager pluginManager;
@Requirement
private Logger logger;
/**

View File

@ -59,29 +59,19 @@ public class DefaultPluginVersionManager
@Requirement
private RuntimeInformation runtimeInformation;
public String resolvePluginVersion( String groupId,
String artifactId,
MavenProject project,
MavenSession session )
public String resolvePluginVersion( String groupId, String artifactId, MavenProject project, MavenSession session )
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
{
return resolvePluginVersion( groupId, artifactId, project, session.getLocalRepository(), false );
}
public String resolveReportPluginVersion( String groupId,
String artifactId,
MavenProject project,
MavenSession session )
public String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project, MavenSession session )
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
{
return resolvePluginVersion( groupId, artifactId, project, session.getLocalRepository(), true );
}
private String resolvePluginVersion( String groupId,
String artifactId,
MavenProject project,
ArtifactRepository localRepository,
boolean resolveAsReportPlugin )
private String resolvePluginVersion( String groupId, String artifactId, MavenProject project, ArtifactRepository localRepository, boolean resolveAsReportPlugin )
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
{
// first pass...if the plugin is specified in the pom, try to retrieve the version from there.

View File

@ -29,6 +29,7 @@ import org.apache.maven.Maven;
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.repository.DefaultArtifactRepository;
import org.apache.maven.embedder.Configuration;
import org.apache.maven.embedder.MavenEmbedder;
import org.apache.maven.embedder.MavenEmbedderException;
@ -325,9 +326,16 @@ public class DefaultMavenExecutionRequestPopulator
{
// Check to see if we have a valid mirror for this repository
ArtifactRepository mirror = repositorySystem.getMirror( repository );
if ( mirror != null )
{
// Make sure that we take the the properties of the repository we are mirroring we want to direct
// all requests for this mirror at the mirror, but the mirror specification does not allow for
// any of the regular settings.
mirror.setLayout( repository.getLayout() );
mirror.setSnapshotUpdatePolicy( repository.getSnapshots() );
mirror.setReleaseUpdatePolicy( repository.getReleases() );
// If there is a valid mirror for this repository then we'll enter the mirror as a replacement for this repository.
remoteRepositoriesWithMirrors.add( mirror );
}

View File

@ -243,6 +243,9 @@ public class MavenProject
}
}
setRemoteArtifactRepositories( projectBuilderConfiguration.getRemoteRepositories() );
/*
try
{
Set<Repository> repoSet = new LinkedHashSet<Repository>();
@ -262,6 +265,7 @@ public class MavenProject
{
e.printStackTrace();
}
*/
}
/**

View File

@ -43,7 +43,6 @@ import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Relocation;
import org.apache.maven.project.DefaultProjectBuilderConfiguration;
import org.apache.maven.project.InvalidProjectModelException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
@ -354,9 +353,9 @@ public class MavenMetadataSource
}
}
List repositories = aggregateRepositoryLists( remoteRepositories, project.getRemoteArtifactRepositories() );
//List repositories = aggregateRepositoryLists( remoteRepositories, project.getRemoteArtifactRepositories() );
result = new ResolutionGroup( pomArtifact, artifacts, repositories );
result = new ResolutionGroup( pomArtifact, artifacts, remoteRepositories );
}
return result;
@ -389,6 +388,7 @@ public class MavenMetadataSource
}
}
/*
private List aggregateRepositoryLists( List remoteRepositories, List remoteArtifactRepositories )
throws ArtifactMetadataRetrievalException
{
@ -445,6 +445,7 @@ public class MavenMetadataSource
return repositories;
}
*/
public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )

View File

@ -75,7 +75,6 @@ public class DefaultMirrorBuilder
}
}
}
}
return selectedMirror;
@ -102,9 +101,7 @@ public class DefaultMirrorBuilder
}
logger.debug( "Using mirror: " + mirror.getId() + " for repository: " + repository.getId() + "\n(mirror url: " + mirror.getUrl() + ")" );
repository = repositoryFactory.createArtifactRepository( id, mirror.getUrl(),
repository.getLayout(), repository.getSnapshots(),
repository.getReleases() );
repository = repositoryFactory.createArtifactRepository( id, mirror.getUrl(), repository.getLayout(), repository.getSnapshots(), repository.getReleases() );
}
return repository;
}