[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@830281 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-10-27 18:17:05 +00:00
parent 6ce5060ddc
commit 3487e9e506
2 changed files with 25 additions and 1 deletions

View File

@ -38,6 +38,8 @@ import org.apache.maven.artifact.repository.metadata.Snapshot;
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.repository.DefaultLocalRepositoryMaintainerEvent;
import org.apache.maven.repository.LocalRepositoryMaintainer;
import org.apache.maven.repository.LocalRepositoryMaintainerEvent;
@ -91,11 +93,25 @@ public class DefaultArtifactResolver
@Requirement( optional = true )
private LocalRepositoryMaintainer localRepositoryMaintainer;
@Requirement
private LegacySupport legacySupport;
private void injectSession( RepositoryRequest request )
{
MavenSession session = legacySupport.getSession();
if ( session != null )
{
request.setOffline( session.isOffline() );
}
}
public void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, TransferListener resolutionListener )
throws ArtifactResolutionException, ArtifactNotFoundException
{
RepositoryRequest request = new DefaultRepositoryRequest();
injectSession( request );
request.setLocalRepository( localRepository );
request.setRemoteRepositories( remoteRepositories );
resolve( artifact, request, resolutionListener, false );
@ -105,6 +121,7 @@ public class DefaultArtifactResolver
throws ArtifactResolutionException, ArtifactNotFoundException
{
RepositoryRequest request = new DefaultRepositoryRequest();
injectSession( request );
request.setLocalRepository( localRepository );
request.setRemoteRepositories( remoteRepositories );
resolve( artifact, request, null, true );
@ -357,6 +374,8 @@ public class DefaultArtifactResolver
.setCollectionFilter( filter )
.setListeners( listeners );
injectSession( request );
return resolveWithExceptions( request );
}

View File

@ -71,6 +71,11 @@ under the License.
<field-name>localRepositoryMaintainer</field-name>
<optional>true</optional>
</requirement>
<requirement>
<role>org.apache.maven.plugin.LegacySupport</role>
<role-hint>default</role-hint>
<field-name>legacySupport</field-name>
</requirement>
</requirements>
</component>
</components>