From ceef52904f772dffab7c8f63a3124001e7fcbefb Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Wed, 31 Mar 2010 19:50:06 +0000 Subject: [PATCH] [MNG-4555] mvn archetype:generate -o (offline) still results in a "checking updates from central" git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@929691 13f79535-47bb-0310-9956-ffa450edef68 --- .../transform/AbstractVersionTransformation.java | 8 ++++++-- .../transform/LatestArtifactTransformation.java | 12 +++++------- .../transform/ReleaseArtifactTransformation.java | 12 +++++------- .../resolver/transform/SnapshotTransformation.java | 13 ------------- 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/AbstractVersionTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/AbstractVersionTransformation.java index 4afb2744c4..b1c4a0c605 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/AbstractVersionTransformation.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/AbstractVersionTransformation.java @@ -55,10 +55,14 @@ public abstract class AbstractVersionTransformation @Requirement protected WagonManager wagonManager; - public void transformForResolve( Artifact artifact, RepositoryRequest request ) + public void transformForResolve( Artifact artifact, List remoteRepositories, + ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException { - transformForResolve( artifact, request.getRemoteRepositories(), request.getLocalRepository() ); + RepositoryRequest request = new DefaultRepositoryRequest(); + request.setLocalRepository( localRepository ); + request.setRemoteRepositories( remoteRepositories ); + transformForResolve( artifact, request ); } protected String resolveVersion( Artifact artifact, ArtifactRepository localRepository, diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/LatestArtifactTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/LatestArtifactTransformation.java index 6dfe527159..616a86545e 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/LatestArtifactTransformation.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/LatestArtifactTransformation.java @@ -19,10 +19,9 @@ package org.apache.maven.repository.legacy.resolver.transform; * under the License. */ -import java.util.List; - import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; @@ -33,23 +32,22 @@ import org.codehaus.plexus.component.annotations.Component; public class LatestArtifactTransformation extends AbstractVersionTransformation { - public void transformForResolve( Artifact artifact, - List remoteRepositories, - ArtifactRepository localRepository ) + + public void transformForResolve( Artifact artifact, RepositoryRequest request ) throws ArtifactResolutionException, ArtifactNotFoundException { if ( Artifact.LATEST_VERSION.equals( artifact.getVersion() ) ) { try { - String version = resolveVersion( artifact, localRepository, remoteRepositories ); + String version = resolveVersion( artifact, request ); if ( Artifact.LATEST_VERSION.equals( version ) ) { throw new ArtifactNotFoundException( "Unable to determine the latest version", artifact ); } artifact.setBaseVersion( version ); - artifact.updateVersion( version, localRepository ); + artifact.updateVersion( version, request.getLocalRepository() ); } catch ( RepositoryMetadataResolutionException e ) { diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java index 95262b6e64..696620d48f 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java @@ -19,11 +19,10 @@ package org.apache.maven.repository.legacy.resolver.transform; * under the License. */ -import java.util.List; - import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; import org.apache.maven.artifact.repository.metadata.Versioning; @@ -41,16 +40,15 @@ import org.codehaus.plexus.component.annotations.Component; public class ReleaseArtifactTransformation extends AbstractVersionTransformation { - public void transformForResolve( Artifact artifact, - List remoteRepositories, - ArtifactRepository localRepository ) + + public void transformForResolve( Artifact artifact, RepositoryRequest request ) throws ArtifactResolutionException, ArtifactNotFoundException { if ( Artifact.RELEASE_VERSION.equals( artifact.getVersion() ) ) { try { - String version = resolveVersion( artifact, localRepository, remoteRepositories ); + String version = resolveVersion( artifact, request ); if ( Artifact.RELEASE_VERSION.equals( version ) ) { @@ -58,7 +56,7 @@ public class ReleaseArtifactTransformation } artifact.setBaseVersion( version ); - artifact.updateVersion( version, localRepository ); + artifact.updateVersion( version, request.getLocalRepository() ); } catch ( RepositoryMetadataResolutionException e ) { diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/SnapshotTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/SnapshotTransformation.java index a9e2c58ab2..049f701f49 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/SnapshotTransformation.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/SnapshotTransformation.java @@ -22,13 +22,11 @@ package org.apache.maven.repository.legacy.resolver.transform; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.List; import java.util.TimeZone; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.DefaultRepositoryRequest; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; @@ -36,7 +34,6 @@ import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutio 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.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.StringUtils; @@ -56,16 +53,6 @@ public class SnapshotTransformation private static final String UTC_TIMESTAMP_PATTERN = "yyyyMMdd.HHmmss"; - public void transformForResolve( Artifact artifact, List remoteRepositories, - ArtifactRepository localRepository ) - throws ArtifactResolutionException, ArtifactNotFoundException - { - RepositoryRequest request = new DefaultRepositoryRequest(); - request.setLocalRepository( localRepository ); - request.setRemoteRepositories( remoteRepositories ); - transformForResolve( artifact, request ); - } - public void transformForResolve( Artifact artifact, RepositoryRequest request ) throws ArtifactResolutionException {