restore more backward comp.

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@944465 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2010-05-14 20:59:30 +00:00
parent 35e842ab22
commit 7f42e485ca
3 changed files with 45 additions and 2 deletions

View File

@ -23,9 +23,12 @@ import java.util.List;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.repository.MirrorSelector;
import org.apache.maven.settings.Mirror;
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Server;
import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
@ -37,6 +40,7 @@ import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.apache.maven.wagon.proxy.ProxyInfo;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
@Component(role=WagonManager.class)
public class DefaultWagonManager
@ -44,12 +48,21 @@ public class DefaultWagonManager
implements WagonManager
{
@Requirement
private Logger logger;
@Requirement
private LegacySupport legacySupport;
@Requirement
private SettingsDecrypter settingsDecrypter;
@Requirement
private MirrorSelector mirrorSelector;
@Requirement
private ArtifactRepositoryFactory artifactRepositoryFactory;
public AuthenticationInfo getAuthenticationInfo( String id )
{
MavenSession session = legacySupport.getSession();
@ -140,5 +153,29 @@ public class DefaultWagonManager
{
getArtifact( artifact, remoteRepositories, null, false );
}
@Deprecated
public ArtifactRepository getMirrorRepository( ArtifactRepository repository )
{
Mirror mirror = mirrorSelector.getMirror( repository, legacySupport.getSession().getSettings().getMirrors() );
if ( mirror != null )
{
String id = mirror.getId();
if ( id == null )
{
// TODO: this should be illegal in settings.xml
id = repository.getId();
}
logger.debug( "Using mirror: " + mirror.getUrl() + " (id: " + id + ")" );
repository = artifactRepositoryFactory.createArtifactRepository( id, mirror.getUrl(),
repository.getLayout(), repository.getSnapshots(),
repository.getReleases() );
}
return repository;
}
}

View File

@ -52,5 +52,7 @@ public interface WagonManager
void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepositories )
throws TransferFailedException, ResourceDoesNotExistException;
ArtifactRepository getMirrorRepository( ArtifactRepository repository );
}

View File

@ -31,6 +31,8 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.repository.MirrorSelector;
import org.apache.maven.settings.Mirror;
import org.apache.maven.wagon.ConnectionException;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
@ -71,7 +73,8 @@ public class DefaultWagonManager
@Requirement
private UpdateCheckManager updateCheckManager;
//
// Retriever
//
@ -758,4 +761,5 @@ public class DefaultWagonManager
return wagon;
}
}