[MNG-4334] maven core caches settings.xml

o First pass: auth & mirror moved out of the components into the requests

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@810296 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-09-01 22:49:05 +00:00
parent b8b148cf8b
commit 3c34aa8c14
21 changed files with 253 additions and 103 deletions

View File

@ -181,7 +181,7 @@ END SNIPPET: ant-bootstrap -->
<modello file="maven-model/src/main/mdo/maven.mdo" version="4.0.0" />
<modello file="maven-plugin-api/src/main/mdo/lifecycle.mdo" />
<modello file="maven-model-builder/src/main/mdo/profiles.mdo" />
<modello file="maven-core/src/main/mdo/settings.mdo" />
<modello file="maven-compat/src/main/mdo/settings.mdo" />
<modello file="maven-core/src/main/mdo/toolchains.mdo" />
<modello file="maven-compat/src/main/mdo/metadata.mdo" />
<modello file="maven-compat/src/main/mdo/profiles.mdo" />

View File

@ -79,6 +79,7 @@
<model>src/main/mdo/metadata.mdo</model>
<model>src/main/mdo/profiles.mdo</model>
<model>src/main/mdo/paramdoc.mdo</model>
<model>src/main/mdo/settings.mdo</model>
</models>
</configuration>
</plugin>

View File

@ -34,9 +34,9 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
// This class needs to stick around because it was exposed the the remote resources plugin started using it instead of
// getting the repositories from the project.
@Deprecated
public final class ProjectUtils
{
static RepositorySystem rs;
private ProjectUtils()
{
@ -53,7 +53,10 @@ public final class ProjectUtils
remoteRepositories.add( buildArtifactRepository( r, artifactRepositoryFactory, c ) );
}
remoteRepositories = rs( c ).getMirrors( remoteRepositories );
/*
* FIXME: The bad dependency relation between maven-core and maven-compat prevents access to LegacySupport here
* which is required to get the mirror&authentication settings from the session/request.
*/
return remoteRepositories;
}
@ -61,6 +64,10 @@ public final class ProjectUtils
public static ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo, ArtifactRepositoryFactory artifactRepositoryFactory, PlexusContainer c )
throws InvalidRepositoryException
{
/*
* FIXME: The bad dependency relation between maven-core and maven-compat prevents access to LegacySupport here
* which is required to get the authentication settings from the session/request.
*/
return rs( c ).buildArtifactRepository( repo );
}
@ -74,12 +81,12 @@ public final class ProjectUtils
{
try
{
rs = c.lookup( RepositorySystem.class );
return c.lookup( RepositorySystem.class );
}
catch ( ComponentLookupException e )
{
throw new IllegalStateException( e );
}
}
return rs;
}
}

View File

@ -163,7 +163,7 @@ public class DefaultMirrorBuilder
* @param pattern used for match. Currently only '*' is supported.
* @return true if the repository is a match to this pattern.
*/
boolean matchPattern( ArtifactRepository originalRepository, String pattern )
static boolean matchPattern( ArtifactRepository originalRepository, String pattern )
{
boolean result = false;
String originalId = originalRepository.getId();
@ -218,7 +218,7 @@ public class DefaultMirrorBuilder
* @param originalRepository
* @return true if external.
*/
boolean isExternalRepo( ArtifactRepository originalRepository )
static boolean isExternalRepo( ArtifactRepository originalRepository )
{
try
{

View File

@ -47,9 +47,10 @@ import org.apache.maven.repository.DelegatingLocalArtifactRepository;
import org.apache.maven.repository.LocalArtifactRepository;
import org.apache.maven.repository.MetadataResolutionRequest;
import org.apache.maven.repository.MetadataResolutionResult;
import org.apache.maven.repository.MirrorBuilder;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.repository.legacy.WagonManager;
import org.apache.maven.settings.Mirror;
import org.apache.maven.settings.Server;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.events.TransferListener;
@ -78,17 +79,13 @@ public class LegacyRepositorySystem
@Requirement( role = ArtifactRepositoryLayout.class )
private Map<String, ArtifactRepositoryLayout> layouts;
@Requirement
private MirrorBuilder mirrorBuilder;
@Requirement
private WagonManager wagonManager;
@Requirement
private PlexusContainer plexus;
private Map<String, Authentication> authentications = new HashMap<String, Authentication>();
// TODO: move this out, the component needs to be stateless for safe reuse
private Map<String, Proxy> proxies = new HashMap<String,Proxy>();
public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type )
@ -329,18 +326,6 @@ public class LegacyRepositorySystem
}
*/
// Mirror
public void addMirror( String id, String mirrorOf, String url )
{
Authentication auth = id != null ? authentications.get( id ) : null;
mirrorBuilder.addMirror( id, mirrorOf, url, auth );
}
public List<ArtifactRepository> getMirrors( List<ArtifactRepository> repositories )
{
return mirrorBuilder.getMirrors( repositories );
}
public List<ArtifactRepository> getEffectiveRepositories( List<ArtifactRepository> repositories )
{
if ( repositories == null )
@ -392,6 +377,8 @@ public class LegacyRepositorySystem
ArtifactRepository effectiveRepository =
createArtifactRepository( aliasedRepo.getId(), aliasedRepo.getUrl(), aliasedRepo.getLayout(), snapshotPolicy, releasePolicy );
effectiveRepository.setAuthentication( aliasedRepo.getAuthentication() );
effectiveRepositories.add( effectiveRepository );
}
@ -466,6 +453,84 @@ public class LegacyRepositorySystem
}
}
private Mirror getMirror( ArtifactRepository repository, List<Mirror> mirrors )
{
String repoId = repository.getId();
if ( repoId != null )
{
for ( Mirror mirror : mirrors )
{
if ( repoId.equals( mirror.getMirrorOf() ) )
{
return mirror;
}
}
for ( Mirror mirror : mirrors )
{
if ( DefaultMirrorBuilder.matchPattern( repository, mirror.getMirrorOf() ) )
{
return mirror;
}
}
}
return null;
}
public void injectMirror( List<ArtifactRepository> repositories, List<Mirror> mirrors )
{
if ( repositories != null && mirrors != null )
{
for ( ArtifactRepository repository : repositories )
{
Mirror mirror = getMirror( repository, mirrors );
if ( mirror != null )
{
repository.setId( mirror.getId() );
repository.setUrl( mirror.getUrl() );
}
}
}
}
public void injectAuthentication( List<ArtifactRepository> repositories, List<Server> servers )
{
if ( repositories != null )
{
Map<String, Server> serversById = new HashMap<String, Server>();
if ( servers != null )
{
for ( Server server : servers )
{
if ( !serversById.containsKey( server.getId() ) )
{
serversById.put( server.getId(), server );
}
}
}
for ( ArtifactRepository repository : repositories )
{
Server server = serversById.get( repository.getId() );
if ( server != null )
{
Authentication authentication = new Authentication( server.getUsername(), server.getPassword() );
repository.setAuthentication( authentication );
}
else
{
repository.setAuthentication( null );
}
}
}
}
public MetadataResolutionResult resolveMetadata( MetadataResolutionRequest request )
{
@ -495,15 +560,6 @@ public class LegacyRepositorySystem
wagonManager.putRemoteFile( repository, source, remotePath, downloadMonitor );
}
//
// serverId = repository id
//
public void addAuthenticationForArtifactRepository( String repositoryId, String username, String password )
{
Authentication authentication = new Authentication( username, password );
authentications.put( repositoryId, authentication );
}
//
// Artifact Repository Creation
//
@ -556,13 +612,6 @@ public class LegacyRepositorySystem
ArtifactRepository artifactRepository = artifactRepositoryFactory.createArtifactRepository( repositoryId, url, repositoryLayout, snapshots, releases );
Authentication authentication = authentications.get( repositoryId );
if ( authentication != null )
{
artifactRepository.setAuthentication( authentication );
}
Proxy proxy = proxies.get( artifactRepository.getProtocol() );
if ( proxy != null )

View File

@ -32,6 +32,8 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.Repository;
import org.apache.maven.settings.Mirror;
import org.apache.maven.settings.Server;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.events.TransferListener;
@ -90,15 +92,32 @@ public interface RepositorySystem
*/
List<ArtifactRepository> getEffectiveRepositories( List<ArtifactRepository> repositories );
/**
* Injects the mirroring information into the specified repositories. For each repository that is matched by a
* mirror, its URL and ID will be updated to match the values from the mirror specification. Repositories without a
* matching mirror will pass through unchanged. <em>Note:</em> This method must be called before
* {@link #injectAuthentication(List, List)} or the repositories will end up with the wrong credentials.
*
* @param repositories The repositories into which to inject the mirror information, may be {@code null}.
* @param mirrors The available mirrors, may be {@code null}.
*/
void injectMirror( List<ArtifactRepository> repositories, List<Mirror> mirrors );
/**
* Injects the authentication information into the specified repositories. For each repository that is matched by a
* server, its credentials will be updated to match the values from the server specification. Repositories without a
* matching server will have their credentials cleared. <em>Note:</em> This method must be called before
* {@link #injectAuthentication(List, List)} or the repositories will end up with the wrong credentials.
*
* @param repositories The repositories into which to inject the authentication information, may be {@code null}.
* @param servers The available servers, may be {@code null}.
*/
void injectAuthentication( List<ArtifactRepository> repositories, List<Server> servers );
ArtifactResolutionResult resolve( ArtifactResolutionRequest request );
MetadataResolutionResult resolveMetadata( MetadataResolutionRequest request );
//TODO: remove the request should already be processed to select the mirror for the request instead of the processing happen internally.
// Mirrors
void addMirror( String id, String mirrorOf, String url );
List<ArtifactRepository> getMirrors( List<ArtifactRepository> repositories );
// Install
// Deploy
@ -114,7 +133,5 @@ public interface RepositorySystem
void retrieve( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor )
throws TransferFailedException, ResourceDoesNotExistException;
void addAuthenticationForArtifactRepository( String repositoryId, String username, String password );
void addProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts );
}

View File

@ -16,18 +16,13 @@ package org.apache.maven.repository.legacy;
*/
import java.io.File;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collections;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.Authentication;
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.model.Dependency;
import org.apache.maven.repository.LegacyRepositorySystem;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.settings.Server;
import org.codehaus.plexus.PlexusTestCase;
/**
@ -67,11 +62,18 @@ public class LegacyRepositorySystemTest
public void testAuthenticationHandling()
throws Exception
{
repositorySystem.addAuthenticationForArtifactRepository( "repository", "jason", "abc123" );
ArtifactRepository repository = repositorySystem.createArtifactRepository( "repository", "http://foo", null, null, null );
Server server = new Server();
server.setId( "repository" );
server.setUsername( "jason" );
server.setPassword( "abc123" );
ArtifactRepository repository =
repositorySystem.createArtifactRepository( "repository", "http://foo", null, null, null );
repositorySystem.injectAuthentication( Arrays.asList( repository ), Arrays.asList( server ) );
Authentication authentication = repository.getAuthentication();
assertNotNull( authentication );
assertEquals( "jason", authentication.getUsername() );
assertEquals( "abc123", authentication.getPassword() );
}
}

View File

@ -103,7 +103,6 @@
<configuration>
<version>1.0.0</version>
<models>
<model>src/main/mdo/settings.mdo</model>
<model>src/main/mdo/toolchains.mdo</model>
</models>
</configuration>

View File

@ -965,6 +965,8 @@ public class DefaultMavenExecutionRequest
projectBuildingRequest.setPluginArtifactRepositories( getPluginArtifactRepositories() );
projectBuildingRequest.setRepositoryCache( getRepositoryCache() );
projectBuildingRequest.setOffline( isOffline() );
projectBuildingRequest.setServers( getServers() );
projectBuildingRequest.setMirrors( getMirrors() );
projectBuildingRequest.setActiveProfileIds( getActiveProfiles() );
projectBuildingRequest.setInactiveProfileIds( getInactiveProfiles() );
projectBuildingRequest.setProfiles( getProfiles() );

View File

@ -85,7 +85,9 @@ public class DefaultMavenProjectBuilder
try
{
ArtifactRepository repo = repositorySystem.buildArtifactRepository( (Repository) repository );
repos.addAll( repositorySystem.getMirrors( Arrays.asList( repo ) ) );
repositorySystem.injectMirror( Arrays.asList( repo ), configuration.getMirrors() );
repositorySystem.injectAuthentication( Arrays.asList( repo ), configuration.getServers() );
repos.add( repo );
}
catch ( InvalidRepositoryException e )
{

View File

@ -114,7 +114,8 @@ class DefaultModelBuildingListener
try
{
remoteRepositories =
projectBuildingHelper.createArtifactRepositories( model.getRepositories(), remoteRepositories );
projectBuildingHelper.createArtifactRepositories( model.getRepositories(), remoteRepositories,
projectBuildingRequest );
}
catch ( Exception e )
{
@ -124,7 +125,8 @@ class DefaultModelBuildingListener
try
{
pluginRepositories =
projectBuildingHelper.createArtifactRepositories( model.getPluginRepositories(), pluginRepositories );
projectBuildingHelper.createArtifactRepositories( model.getPluginRepositories(), pluginRepositories,
projectBuildingRequest );
}
catch ( Exception e )
{

View File

@ -199,14 +199,8 @@ public class DefaultProjectBuilder
private ModelBuildingRequest getModelBuildingRequest( ProjectBuildingRequest configuration,
ReactorModelPool reactorModelPool )
{
RepositoryRequest repositoryRequest = new DefaultRepositoryRequest();
repositoryRequest.setCache( configuration.getRepositoryCache() );
repositoryRequest.setLocalRepository( configuration.getLocalRepository() );
repositoryRequest.setOffline( configuration.isOffline() );
ModelResolver resolver =
new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, repositoryRequest,
configuration.getRemoteRepositories(), reactorModelPool );
new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, configuration, reactorModelPool );
ModelBuildingRequest request = new DefaultModelBuildingRequest();

View File

@ -87,7 +87,8 @@ public class DefaultProjectBuildingHelper
private PluginVersionResolver pluginVersionResolver;
public List<ArtifactRepository> createArtifactRepositories( List<Repository> pomRepositories,
List<ArtifactRepository> externalRepositories )
List<ArtifactRepository> externalRepositories,
ProjectBuildingRequest request )
throws InvalidRepositoryException
{
List<ArtifactRepository> artifactRepositories = new ArrayList<ArtifactRepository>();
@ -97,7 +98,9 @@ public class DefaultProjectBuildingHelper
artifactRepositories.add( repositorySystem.buildArtifactRepository( repository ) );
}
artifactRepositories = repositorySystem.getMirrors( artifactRepositories );
repositorySystem.injectMirror( artifactRepositories, request.getMirrors() );
repositorySystem.injectAuthentication( artifactRepositories, request.getServers() );
if ( externalRepositories != null )
{

View File

@ -29,6 +29,8 @@ import org.apache.maven.artifact.repository.RepositoryCache;
import org.apache.maven.model.Profile;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.building.ModelEventListener;
import org.apache.maven.settings.Mirror;
import org.apache.maven.settings.Server;
public class DefaultProjectBuildingRequest
implements ProjectBuildingRequest
@ -44,6 +46,10 @@ public class DefaultProjectBuildingRequest
private List<ArtifactRepository> pluginArtifactRepositories;
private List<Server> servers;
private List<Mirror> mirrors;
private List<ModelEventListener> listeners;
private MavenProject project;
@ -79,6 +85,8 @@ public class DefaultProjectBuildingRequest
userProperties = new Properties();
remoteRepositories = new ArrayList<ArtifactRepository>();
pluginArtifactRepositories = new ArrayList<ArtifactRepository>();
servers = new ArrayList<Server>();
mirrors = new ArrayList<Mirror>();
}
public MavenProject getProject()
@ -164,6 +172,44 @@ public class DefaultProjectBuildingRequest
return this;
}
public ProjectBuildingRequest setServers( List<Server> servers )
{
if ( servers != null )
{
this.servers = new ArrayList<Server>( servers );
}
else
{
this.servers.clear();
}
return this;
}
public List<Server> getServers()
{
return servers;
}
public ProjectBuildingRequest setMirrors( List<Mirror> mirrors )
{
if ( mirrors != null )
{
this.mirrors = new ArrayList<Mirror>( mirrors );
}
else
{
this.mirrors.clear();
}
return this;
}
public List<Mirror> getMirrors()
{
return mirrors;
}
public Properties getSystemProperties()
{
return systemProperties;

View File

@ -19,6 +19,7 @@ import java.io.File;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@ -1738,7 +1739,10 @@ public class MavenProject
{
try
{
setReleaseArtifactRepository( repositorySystem.buildArtifactRepository( getDistributionManagement().getRepository() ) );
ArtifactRepository repo =
repositorySystem.buildArtifactRepository( getDistributionManagement().getRepository() );
repositorySystem.injectAuthentication( Arrays.asList( repo ), projectBuilderConfiguration.getServers() );
setReleaseArtifactRepository( repo );
}
catch ( InvalidRepositoryException e )
{
@ -1754,7 +1758,10 @@ public class MavenProject
{
try
{
setSnapshotArtifactRepository( repositorySystem.buildArtifactRepository( getDistributionManagement().getSnapshotRepository() ) );
ArtifactRepository repo =
repositorySystem.buildArtifactRepository( getDistributionManagement().getSnapshotRepository() );
repositorySystem.injectAuthentication( Arrays.asList( repo ), projectBuilderConfiguration.getServers() );
setSnapshotArtifactRepository( repo );
}
catch ( InvalidRepositoryException e )
{

View File

@ -46,11 +46,14 @@ public interface ProjectBuildingHelper
* @param pomRepositories The POM repositories to create the artifact repositories from, must not be {@code null}.
* @param externalRepositories The external (and already mirrored) repositories to merge into the result list, may
* be {@code null}.
* @param request The project building request holding further settings like repository settings, must not be
* {@code null}.
* @return The effective artifact repositories, never {@code null}.
* @throws InvalidRepositoryException
*/
List<ArtifactRepository> createArtifactRepositories( List<Repository> pomRepositories,
List<ArtifactRepository> externalRepositories )
List<ArtifactRepository> externalRepositories,
ProjectBuildingRequest request )
throws InvalidRepositoryException;
/**

View File

@ -27,6 +27,8 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.RepositoryCache;
import org.apache.maven.model.Profile;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.settings.Mirror;
import org.apache.maven.settings.Server;
public interface ProjectBuildingRequest
{
@ -51,6 +53,14 @@ public interface ProjectBuildingRequest
List<ArtifactRepository> getPluginArtifactRepositories();
ProjectBuildingRequest setServers( List<Server> servers );
List<Server> getServers();
ProjectBuildingRequest setMirrors( List<Mirror> mirrors );
List<Mirror> getMirrors();
/**
* Sets the system properties to use for interpolation and profile activation. The system properties are collected
* from the runtime environment like {@link System#getProperties()} and environment variables.

View File

@ -26,7 +26,6 @@ import java.util.List;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.RepositoryRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
@ -52,15 +51,14 @@ class RepositoryModelResolver
private ResolutionErrorHandler resolutionErrorHandler;
private RepositoryRequest repositoryRequest;
private ProjectBuildingRequest projectBuildingRequest;
private List<ArtifactRepository> remoteRepositories;
private ReactorModelPool reactorModelPool;
public RepositoryModelResolver( RepositorySystem repositorySystem, ResolutionErrorHandler resolutionErrorHandler,
RepositoryRequest repositoryRequest, List<ArtifactRepository> remoteRepositories,
ReactorModelPool reactorModelPool )
ProjectBuildingRequest projectBuildingRequest, ReactorModelPool reactorModelPool )
{
if ( repositorySystem == null )
{
@ -74,25 +72,25 @@ class RepositoryModelResolver
}
this.resolutionErrorHandler = resolutionErrorHandler;
if ( repositoryRequest == null )
if ( projectBuildingRequest == null )
{
throw new IllegalArgumentException( "no repository request specified" );
throw new IllegalArgumentException( "no project building request specified" );
}
this.repositoryRequest = repositoryRequest;
this.projectBuildingRequest = projectBuildingRequest;
if ( remoteRepositories == null )
if ( projectBuildingRequest.getRemoteRepositories() == null )
{
throw new IllegalArgumentException( "no remote repositories specified" );
}
this.remoteRepositories = new ArrayList<ArtifactRepository>( remoteRepositories );
this.remoteRepositories = new ArrayList<ArtifactRepository>( projectBuildingRequest.getRemoteRepositories() );
this.reactorModelPool = reactorModelPool;
}
public ModelResolver newCopy()
{
return new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, repositoryRequest,
remoteRepositories, reactorModelPool );
return new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, projectBuildingRequest,
reactorModelPool );
}
public void addRepository( Repository repository )
@ -102,9 +100,11 @@ class RepositoryModelResolver
{
ArtifactRepository repo = repositorySystem.buildArtifactRepository( repository );
List<ArtifactRepository> mirrors = repositorySystem.getMirrors( Arrays.asList( repo ) );
repositorySystem.injectMirror( Arrays.asList( repo ), projectBuildingRequest.getMirrors() );
remoteRepositories.addAll( 0, mirrors );
repositorySystem.injectAuthentication( Arrays.asList( repo ), projectBuildingRequest.getServers() );
remoteRepositories.add( 0, repo );
remoteRepositories = repositorySystem.getEffectiveRepositories( remoteRepositories );
}
@ -128,9 +128,12 @@ class RepositoryModelResolver
{
Artifact artifactParent = repositorySystem.createProjectArtifact( groupId, artifactId, version );
ArtifactResolutionRequest request = new ArtifactResolutionRequest( repositoryRequest );
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setArtifact( artifactParent );
request.setRemoteRepositories( remoteRepositories );
request.setLocalRepository( projectBuildingRequest.getLocalRepository() );
request.setOffline( projectBuildingRequest.isOffline() );
request.setCache( projectBuildingRequest.getRepositoryCache() );
// FIXME setTransferListener
ArtifactResolutionResult result = repositorySystem.resolve( request );

View File

@ -42,7 +42,8 @@ public class EmptyProjectBuildingHelper
{
public List<ArtifactRepository> createArtifactRepositories( List<Repository> pomRepositories,
List<ArtifactRepository> externalRepositories )
List<ArtifactRepository> externalRepositories,
ProjectBuildingRequest request )
throws InvalidRepositoryException
{
if ( externalRepositories != null )

View File

@ -229,17 +229,6 @@ public class DefaultMavenExecutionRequestPopulator
server.setPassword( password );
request.addServer( server );
repositorySystem.addAuthenticationForArtifactRepository( server.getId(), server.getUsername(), password );
}
for ( Mirror mirror : settings.getMirrors() )
{
mirror = mirror.clone();
request.addMirror( mirror );
repositorySystem.addMirror( mirror.getId(), mirror.getMirrorOf(), mirror.getUrl() );
}
// <mirrors>
@ -250,9 +239,22 @@ public class DefaultMavenExecutionRequestPopulator
// </mirror>
// </mirrors>
request.setRemoteRepositories( repositorySystem.getMirrors( request.getRemoteRepositories() ) );
for ( Mirror mirror : settings.getMirrors() )
{
mirror = mirror.clone();
request.setPluginArtifactRepositories( repositorySystem.getMirrors( request.getPluginArtifactRepositories() ) );
request.addMirror( mirror );
}
repositorySystem.injectMirror( request.getRemoteRepositories(), request.getMirrors() );
repositorySystem.injectAuthentication( request.getRemoteRepositories(), request.getServers() );
request.setRemoteRepositories( repositorySystem.getEffectiveRepositories( request.getRemoteRepositories() ) );
repositorySystem.injectMirror( request.getPluginArtifactRepositories(), request.getMirrors() );
repositorySystem.injectAuthentication( request.getPluginArtifactRepositories(), request.getServers() );
request.setPluginArtifactRepositories( repositorySystem.getEffectiveRepositories( request.getPluginArtifactRepositories() ) );
}
private String decrypt( String encrypted, String source )