mirror of https://github.com/apache/maven.git
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:
parent
3b4dd11674
commit
1a05bdac38
|
@ -35,8 +35,7 @@ public interface ArtifactRepository
|
||||||
|
|
||||||
String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata );
|
String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata );
|
||||||
|
|
||||||
String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata,
|
String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository );
|
||||||
ArtifactRepository repository );
|
|
||||||
|
|
||||||
String getUrl();
|
String getUrl();
|
||||||
|
|
||||||
|
@ -47,11 +46,14 @@ public interface ArtifactRepository
|
||||||
String getId();
|
String getId();
|
||||||
|
|
||||||
ArtifactRepositoryPolicy getSnapshots();
|
ArtifactRepositoryPolicy getSnapshots();
|
||||||
|
void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy policy );
|
||||||
|
|
||||||
ArtifactRepositoryPolicy getReleases();
|
ArtifactRepositoryPolicy getReleases();
|
||||||
|
void setReleaseUpdatePolicy( ArtifactRepositoryPolicy policy );
|
||||||
|
|
||||||
ArtifactRepositoryLayout getLayout();
|
ArtifactRepositoryLayout getLayout();
|
||||||
|
void setLayout( ArtifactRepositoryLayout layout );
|
||||||
|
|
||||||
String getKey();
|
String getKey();
|
||||||
|
|
||||||
boolean isUniqueVersion();
|
boolean isUniqueVersion();
|
||||||
|
|
|
@ -52,9 +52,7 @@ public class DefaultArtifactRepository
|
||||||
* @param url the URL of the repository
|
* @param url the URL of the repository
|
||||||
* @param layout the layout of the repository
|
* @param layout the layout of the repository
|
||||||
*/
|
*/
|
||||||
public DefaultArtifactRepository( String id,
|
public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout )
|
||||||
String url,
|
|
||||||
ArtifactRepositoryLayout layout )
|
|
||||||
{
|
{
|
||||||
this( id, url, layout, null, null );
|
this( id, url, layout, null, null );
|
||||||
}
|
}
|
||||||
|
@ -67,10 +65,7 @@ public class DefaultArtifactRepository
|
||||||
* @param layout the layout of the repository
|
* @param layout the layout of the repository
|
||||||
* @param uniqueVersion whether to assign each snapshot a unique version
|
* @param uniqueVersion whether to assign each snapshot a unique version
|
||||||
*/
|
*/
|
||||||
public DefaultArtifactRepository( String id,
|
public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, boolean uniqueVersion )
|
||||||
String url,
|
|
||||||
ArtifactRepositoryLayout layout,
|
|
||||||
boolean uniqueVersion )
|
|
||||||
{
|
{
|
||||||
super( id, url );
|
super( id, url );
|
||||||
this.layout = layout;
|
this.layout = layout;
|
||||||
|
@ -86,11 +81,7 @@ public class DefaultArtifactRepository
|
||||||
* @param snapshots the policies to use for snapshots
|
* @param snapshots the policies to use for snapshots
|
||||||
* @param releases the policies to use for releases
|
* @param releases the policies to use for releases
|
||||||
*/
|
*/
|
||||||
public DefaultArtifactRepository( String id,
|
public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases )
|
||||||
String url,
|
|
||||||
ArtifactRepositoryLayout layout,
|
|
||||||
ArtifactRepositoryPolicy snapshots,
|
|
||||||
ArtifactRepositoryPolicy releases )
|
|
||||||
{
|
{
|
||||||
super( id, url );
|
super( id, url );
|
||||||
|
|
||||||
|
@ -129,17 +120,27 @@ public class DefaultArtifactRepository
|
||||||
return layout.pathOfLocalRepositoryMetadata( metadata, repository );
|
return layout.pathOfLocalRepositoryMetadata( metadata, repository );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLayout( ArtifactRepositoryLayout layout )
|
||||||
|
{
|
||||||
|
this.layout = layout;
|
||||||
|
}
|
||||||
|
|
||||||
public ArtifactRepositoryLayout getLayout()
|
public ArtifactRepositoryLayout getLayout()
|
||||||
{
|
{
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy snapshots )
|
||||||
|
{
|
||||||
|
this.snapshots = snapshots;
|
||||||
|
}
|
||||||
|
|
||||||
public ArtifactRepositoryPolicy getSnapshots()
|
public ArtifactRepositoryPolicy getSnapshots()
|
||||||
{
|
{
|
||||||
return snapshots;
|
return snapshots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReleases( ArtifactRepositoryPolicy releases )
|
public void setReleaseUpdatePolicy( ArtifactRepositoryPolicy releases )
|
||||||
{
|
{
|
||||||
this.releases = releases;
|
this.releases = releases;
|
||||||
}
|
}
|
||||||
|
@ -168,4 +169,17 @@ public class DefaultArtifactRepository
|
||||||
{
|
{
|
||||||
this.blacklisted = blacklisted;
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,11 @@ public interface ArtifactRepositoryLayout
|
||||||
{
|
{
|
||||||
String ROLE = ArtifactRepositoryLayout.class.getName();
|
String ROLE = ArtifactRepositoryLayout.class.getName();
|
||||||
|
|
||||||
|
String getId();
|
||||||
|
|
||||||
String pathOf( Artifact artifact );
|
String pathOf( Artifact artifact );
|
||||||
|
|
||||||
String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata,
|
String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository );
|
||||||
ArtifactRepository repository );
|
|
||||||
|
|
||||||
String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata );
|
String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata );
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,11 @@ public class DefaultRepositoryLayout
|
||||||
|
|
||||||
private static final char ARTIFACT_SEPARATOR = '-';
|
private static final char ARTIFACT_SEPARATOR = '-';
|
||||||
|
|
||||||
|
public String getId()
|
||||||
|
{
|
||||||
|
return "default";
|
||||||
|
}
|
||||||
|
|
||||||
public String pathOf( Artifact artifact )
|
public String pathOf( Artifact artifact )
|
||||||
{
|
{
|
||||||
ArtifactHandler artifactHandler = artifact.getArtifactHandler();
|
ArtifactHandler artifactHandler = artifact.getArtifactHandler();
|
||||||
|
|
|
@ -20,6 +20,11 @@ public class FlatRepositoryLayout
|
||||||
|
|
||||||
private static final char GROUP_SEPARATOR = '.';
|
private static final char GROUP_SEPARATOR = '.';
|
||||||
|
|
||||||
|
public String getId()
|
||||||
|
{
|
||||||
|
return "flat";
|
||||||
|
}
|
||||||
|
|
||||||
public String pathOf( Artifact artifact )
|
public String pathOf( Artifact artifact )
|
||||||
{
|
{
|
||||||
ArtifactHandler artifactHandler = artifact.getArtifactHandler();
|
ArtifactHandler artifactHandler = artifact.getArtifactHandler();
|
||||||
|
|
|
@ -34,6 +34,11 @@ public class LegacyRepositoryLayout
|
||||||
{
|
{
|
||||||
private static final String PATH_SEPARATOR = "/";
|
private static final String PATH_SEPARATOR = "/";
|
||||||
|
|
||||||
|
public String getId()
|
||||||
|
{
|
||||||
|
return "legacy";
|
||||||
|
}
|
||||||
|
|
||||||
public String pathOf( Artifact artifact )
|
public String pathOf( Artifact artifact )
|
||||||
{
|
{
|
||||||
ArtifactHandler artifactHandler = artifact.getArtifactHandler();
|
ArtifactHandler artifactHandler = artifact.getArtifactHandler();
|
||||||
|
|
|
@ -487,6 +487,11 @@ public class DefaultWagonManagerTest
|
||||||
private final class ArtifactRepositoryLayoutStub
|
private final class ArtifactRepositoryLayoutStub
|
||||||
implements ArtifactRepositoryLayout
|
implements ArtifactRepositoryLayout
|
||||||
{
|
{
|
||||||
|
public String getId()
|
||||||
|
{
|
||||||
|
return "test";
|
||||||
|
}
|
||||||
|
|
||||||
public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata )
|
public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata )
|
||||||
{
|
{
|
||||||
return "path";
|
return "path";
|
||||||
|
|
|
@ -127,8 +127,7 @@ public class DefaultPluginManagerSupport
|
||||||
}
|
}
|
||||||
catch ( ProjectBuildingException e )
|
catch ( ProjectBuildingException e )
|
||||||
{
|
{
|
||||||
throw new InvalidPluginException( "Unable to build project for plugin '"
|
throw new InvalidPluginException( "Unable to build project for plugin '" + plugin.getKey() + "': " + e.getMessage(), e );
|
||||||
+ plugin.getKey() + "': " + e.getMessage(), e );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
import org.codehaus.plexus.component.annotations.Requirement;
|
import org.codehaus.plexus.component.annotations.Requirement;
|
||||||
import org.codehaus.plexus.logging.LogEnabled;
|
|
||||||
import org.codehaus.plexus.logging.Logger;
|
import org.codehaus.plexus.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,11 +28,12 @@ import org.codehaus.plexus.logging.Logger;
|
||||||
*/
|
*/
|
||||||
@Component(role = PluginLoader.class)
|
@Component(role = PluginLoader.class)
|
||||||
public class DefaultPluginLoader
|
public class DefaultPluginLoader
|
||||||
implements PluginLoader, LogEnabled
|
implements PluginLoader
|
||||||
{
|
{
|
||||||
@Requirement
|
@Requirement
|
||||||
private PluginManager pluginManager;
|
private PluginManager pluginManager;
|
||||||
|
|
||||||
|
@Requirement
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -59,29 +59,19 @@ public class DefaultPluginVersionManager
|
||||||
@Requirement
|
@Requirement
|
||||||
private RuntimeInformation runtimeInformation;
|
private RuntimeInformation runtimeInformation;
|
||||||
|
|
||||||
public String resolvePluginVersion( String groupId,
|
public String resolvePluginVersion( String groupId, String artifactId, MavenProject project, MavenSession session )
|
||||||
String artifactId,
|
|
||||||
MavenProject project,
|
|
||||||
MavenSession session )
|
|
||||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
||||||
{
|
{
|
||||||
return resolvePluginVersion( groupId, artifactId, project, session.getLocalRepository(), false );
|
return resolvePluginVersion( groupId, artifactId, project, session.getLocalRepository(), false );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String resolveReportPluginVersion( String groupId,
|
public String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project, MavenSession session )
|
||||||
String artifactId,
|
|
||||||
MavenProject project,
|
|
||||||
MavenSession session )
|
|
||||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
||||||
{
|
{
|
||||||
return resolvePluginVersion( groupId, artifactId, project, session.getLocalRepository(), true );
|
return resolvePluginVersion( groupId, artifactId, project, session.getLocalRepository(), true );
|
||||||
}
|
}
|
||||||
|
|
||||||
private String resolvePluginVersion( String groupId,
|
private String resolvePluginVersion( String groupId, String artifactId, MavenProject project, ArtifactRepository localRepository, boolean resolveAsReportPlugin )
|
||||||
String artifactId,
|
|
||||||
MavenProject project,
|
|
||||||
ArtifactRepository localRepository,
|
|
||||||
boolean resolveAsReportPlugin )
|
|
||||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
||||||
{
|
{
|
||||||
// first pass...if the plugin is specified in the pom, try to retrieve the version from there.
|
// first pass...if the plugin is specified in the pom, try to retrieve the version from there.
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.maven.Maven;
|
||||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
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.Configuration;
|
||||||
import org.apache.maven.embedder.MavenEmbedder;
|
import org.apache.maven.embedder.MavenEmbedder;
|
||||||
import org.apache.maven.embedder.MavenEmbedderException;
|
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
|
// Check to see if we have a valid mirror for this repository
|
||||||
ArtifactRepository mirror = repositorySystem.getMirror( repository );
|
ArtifactRepository mirror = repositorySystem.getMirror( repository );
|
||||||
|
|
||||||
if ( mirror != null )
|
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.
|
// If there is a valid mirror for this repository then we'll enter the mirror as a replacement for this repository.
|
||||||
remoteRepositoriesWithMirrors.add( mirror );
|
remoteRepositoriesWithMirrors.add( mirror );
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,6 +243,9 @@ public class MavenProject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setRemoteArtifactRepositories( projectBuilderConfiguration.getRemoteRepositories() );
|
||||||
|
|
||||||
|
/*
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Set<Repository> repoSet = new LinkedHashSet<Repository>();
|
Set<Repository> repoSet = new LinkedHashSet<Repository>();
|
||||||
|
@ -262,6 +265,7 @@ public class MavenProject
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -43,7 +43,6 @@ import org.apache.maven.artifact.versioning.VersionRange;
|
||||||
import org.apache.maven.model.Dependency;
|
import org.apache.maven.model.Dependency;
|
||||||
import org.apache.maven.model.DistributionManagement;
|
import org.apache.maven.model.DistributionManagement;
|
||||||
import org.apache.maven.model.Relocation;
|
import org.apache.maven.model.Relocation;
|
||||||
import org.apache.maven.project.DefaultProjectBuilderConfiguration;
|
|
||||||
import org.apache.maven.project.InvalidProjectModelException;
|
import org.apache.maven.project.InvalidProjectModelException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.project.MavenProjectBuilder;
|
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;
|
return result;
|
||||||
|
@ -389,6 +388,7 @@ public class MavenMetadataSource
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private List aggregateRepositoryLists( List remoteRepositories, List remoteArtifactRepositories )
|
private List aggregateRepositoryLists( List remoteRepositories, List remoteArtifactRepositories )
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
|
@ -445,6 +445,7 @@ public class MavenMetadataSource
|
||||||
|
|
||||||
return repositories;
|
return repositories;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository,
|
public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository,
|
||||||
List<ArtifactRepository> remoteRepositories )
|
List<ArtifactRepository> remoteRepositories )
|
||||||
|
|
|
@ -75,7 +75,6 @@ public class DefaultMirrorBuilder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return selectedMirror;
|
return selectedMirror;
|
||||||
|
@ -102,9 +101,7 @@ public class DefaultMirrorBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug( "Using mirror: " + mirror.getId() + " for repository: " + repository.getId() + "\n(mirror url: " + mirror.getUrl() + ")" );
|
logger.debug( "Using mirror: " + mirror.getId() + " for repository: " + repository.getId() + "\n(mirror url: " + mirror.getUrl() + ")" );
|
||||||
repository = repositoryFactory.createArtifactRepository( id, mirror.getUrl(),
|
repository = repositoryFactory.createArtifactRepository( id, mirror.getUrl(), repository.getLayout(), repository.getSnapshots(), repository.getReleases() );
|
||||||
repository.getLayout(), repository.getSnapshots(),
|
|
||||||
repository.getReleases() );
|
|
||||||
}
|
}
|
||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue