mirror of https://github.com/apache/maven.git
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:
parent
c9be3d3c40
commit
18b47d1650
|
@ -19,6 +19,8 @@ package org.apache.maven;
|
||||||
|
|
||||||
import org.apache.maven.artifact.manager.WagonManager;
|
import org.apache.maven.artifact.manager.WagonManager;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
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.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
import org.apache.maven.execution.BuildFailure;
|
import org.apache.maven.execution.BuildFailure;
|
||||||
|
@ -104,6 +106,8 @@ public class DefaultMaven
|
||||||
protected LoggerManager loggerManager;
|
protected LoggerManager loggerManager;
|
||||||
|
|
||||||
protected MavenTools mavenTools;
|
protected MavenTools mavenTools;
|
||||||
|
|
||||||
|
protected ArtifactRepositoryFactory artifactRepositoryFactory;
|
||||||
|
|
||||||
private static final long MB = 1024 * 1024;
|
private static final long MB = 1024 * 1024;
|
||||||
|
|
||||||
|
@ -118,6 +122,20 @@ public class DefaultMaven
|
||||||
public void execute( MavenExecutionRequest request )
|
public void execute( MavenExecutionRequest request )
|
||||||
throws MavenExecutionException
|
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 )
|
if ( request.getLocalRepository() == null )
|
||||||
{
|
{
|
||||||
request.setLocalRepository( mavenTools.createLocalRepository( request.getLocalRepositoryPath() ) );
|
request.setLocalRepository( mavenTools.createLocalRepository( request.getLocalRepositoryPath() ) );
|
||||||
|
|
|
@ -85,6 +85,9 @@
|
||||||
<requirement>
|
<requirement>
|
||||||
<role>org.apache.maven.MavenTools</role>
|
<role>org.apache.maven.MavenTools</role>
|
||||||
</requirement>
|
</requirement>
|
||||||
|
<requirement>
|
||||||
|
<role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
|
||||||
|
</requirement>
|
||||||
</requirements>
|
</requirements>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
|
|
@ -61,32 +61,14 @@ public class DefaultMavenTools
|
||||||
localRepositoryUrl = "file://" + localRepositoryUrl;
|
localRepositoryUrl = "file://" + localRepositoryUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return createRepository( "local", localRepositoryUrl, false, true, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
|
return createRepository( "local", localRepositoryUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactRepository createRepository( String repositoryId,
|
private ArtifactRepository createRepository( String repositoryId,
|
||||||
String repositoryUrl,
|
String repositoryUrl)
|
||||||
boolean offline,
|
|
||||||
boolean updateSnapshots,
|
|
||||||
String globalChecksumPolicy )
|
|
||||||
{
|
{
|
||||||
ArtifactRepository localRepository =
|
ArtifactRepository localRepository =
|
||||||
new DefaultArtifactRepository( repositoryId, repositoryUrl, repositoryLayout );
|
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;
|
return localRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue