[MNG-4412] Make legacy entry points to repository system pick offline mode from session

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@834919 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-11-11 15:46:56 +00:00
parent 1acffe2e2b
commit 42ed0ede91
1 changed files with 20 additions and 0 deletions

View File

@ -45,6 +45,8 @@ import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.ManagedVersionMap;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.repository.legacy.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.repository.legacy.metadata.DefaultMetadataResolutionRequest;
import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
@ -67,6 +69,23 @@ public class DefaultLegacyArtifactCollector
@Requirement
private Logger logger;
@Requirement
private LegacySupport legacySupport;
private void injectSession( ArtifactResolutionRequest request )
{
MavenSession session = legacySupport.getSession();
if ( session != null )
{
request.setOffline( session.isOffline() );
request.setServers( session.getRequest().getServers() );
request.setMirrors( session.getRequest().getMirrors() );
request.setProxies( session.getRequest().getProxies() );
request.setTransferListener( session.getRequest().getTransferListener() );
}
}
public ArtifactResolutionResult collect( Set<Artifact> artifacts,
Artifact originatingArtifact,
Map managedVersions,
@ -80,6 +99,7 @@ public class DefaultLegacyArtifactCollector
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setLocalRepository( localRepository );
request.setRemoteRepositories( remoteRepositories );
injectSession( request );
return collect( artifacts, originatingArtifact, managedVersions, request, source, filter, listeners,
conflictResolvers );
}