when creating local repository, don't force updating snapshots from all remote repositories.

handle according to the executionrequest

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@418631 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Milos Kleint 2006-07-02 18:00:48 +00:00
parent c9be3d3c40
commit 18b47d1650
3 changed files with 24 additions and 21 deletions

View File

@ -19,6 +19,8 @@ package org.apache.maven;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.execution.BuildFailure;
@ -105,6 +107,8 @@ public class DefaultMaven
protected MavenTools mavenTools;
protected ArtifactRepositoryFactory artifactRepositoryFactory;
private static final long MB = 1024 * 1024;
private static final int MS_PER_SEC = 1000;
@ -118,6 +122,20 @@ public class DefaultMaven
public void execute( MavenExecutionRequest request )
throws MavenExecutionException
{
boolean snapshotPolicySet = false;
if ( request.isOffline() )
{
snapshotPolicySet = true;
}
if ( !snapshotPolicySet && request.isUpdateSnapshots() )
{
artifactRepositoryFactory.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS );
}
artifactRepositoryFactory.setGlobalChecksumPolicy( request.getGlobalChecksumPolicy() );
if ( request.getLocalRepository() == null )
{
request.setLocalRepository( mavenTools.createLocalRepository( request.getLocalRepositoryPath() ) );

View File

@ -85,6 +85,9 @@
<requirement>
<role>org.apache.maven.MavenTools</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
</requirement>
</requirements>
</component>

View File

@ -61,32 +61,14 @@ public class DefaultMavenTools
localRepositoryUrl = "file://" + localRepositoryUrl;
}
return createRepository( "local", localRepositoryUrl, false, true, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
return createRepository( "local", localRepositoryUrl);
}
public ArtifactRepository createRepository( String repositoryId,
String repositoryUrl,
boolean offline,
boolean updateSnapshots,
String globalChecksumPolicy )
private ArtifactRepository createRepository( String repositoryId,
String repositoryUrl)
{
ArtifactRepository localRepository =
new DefaultArtifactRepository( repositoryId, repositoryUrl, repositoryLayout );
boolean snapshotPolicySet = false;
if ( offline )
{
snapshotPolicySet = true;
}
if ( !snapshotPolicySet && updateSnapshots )
{
artifactRepositoryFactory.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS );
}
artifactRepositoryFactory.setGlobalChecksumPolicy( globalChecksumPolicy );
return localRepository;
}