From 18b47d16506909c3907f9addad1a221fdd54a2ee Mon Sep 17 00:00:00 2001 From: Milos Kleint Date: Sun, 2 Jul 2006 18:00:48 +0000 Subject: [PATCH] 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 --- .../java/org/apache/maven/DefaultMaven.java | 18 ++++++++++++++ .../resources/META-INF/plexus/components.xml | 3 +++ .../org/apache/maven/DefaultMavenTools.java | 24 +++---------------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index 42f8d4059b..1d41ccd497 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -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; @@ -104,6 +106,8 @@ public class DefaultMaven protected LoggerManager loggerManager; protected MavenTools mavenTools; + + protected ArtifactRepositoryFactory artifactRepositoryFactory; private static final long MB = 1024 * 1024; @@ -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() ) ); diff --git a/maven-core/src/main/resources/META-INF/plexus/components.xml b/maven-core/src/main/resources/META-INF/plexus/components.xml index 83c90b705d..6f6533c69e 100644 --- a/maven-core/src/main/resources/META-INF/plexus/components.xml +++ b/maven-core/src/main/resources/META-INF/plexus/components.xml @@ -85,6 +85,9 @@ org.apache.maven.MavenTools + + org.apache.maven.artifact.repository.ArtifactRepositoryFactory + diff --git a/maven-tools/src/main/java/org/apache/maven/DefaultMavenTools.java b/maven-tools/src/main/java/org/apache/maven/DefaultMavenTools.java index 865a99eec2..d4e3f85c94 100644 --- a/maven-tools/src/main/java/org/apache/maven/DefaultMavenTools.java +++ b/maven-tools/src/main/java/org/apache/maven/DefaultMavenTools.java @@ -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; }