From 5d459b0c0ed4ad83a90044cb214263782eeeee6d Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Wed, 16 Sep 2009 23:07:41 +0000 Subject: [PATCH] [MNG-4361] [regression] command line option "-update-snapshots" does not work git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@816002 13f79535-47bb-0310-9956-ffa450edef68 --- .../repository/DefaultRepositoryRequest.java | 15 +++++++++++++++ .../artifact/repository/RepositoryRequest.java | 18 ++++++++++++++++++ .../DefaultRepositoryMetadataManager.java | 3 ++- .../resolver/ArtifactResolutionRequest.java | 15 +++++++++++++++ .../DefaultMetadataResolutionRequest.java | 12 ++++++++++++ .../DefaultProjectDependenciesResolver.java | 1 + .../prefix/DefaultPluginPrefixRequest.java | 12 ++++++++++++ .../version/DefaultPluginVersionRequest.java | 12 ++++++++++++ .../maven/project/DefaultProjectBuilder.java | 4 +++- .../project/DefaultProjectBuildingRequest.java | 14 ++++++++++++++ .../maven/project/ProjectBuildingRequest.java | 4 ++++ .../project/artifact/MavenMetadataSource.java | 1 + 12 files changed, 109 insertions(+), 2 deletions(-) diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultRepositoryRequest.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultRepositoryRequest.java index 1d4a8ac865..78b5488771 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultRepositoryRequest.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultRepositoryRequest.java @@ -33,6 +33,8 @@ public class DefaultRepositoryRequest private boolean offline; + private boolean forceUpdate; + private ArtifactRepository localRepository; private List remoteRepositories; @@ -58,6 +60,7 @@ public class DefaultRepositoryRequest setRemoteRepositories( repositoryRequest.getRemoteRepositories() ); setOffline( repositoryRequest.isOffline() ); setCache( repositoryRequest.getCache() ); + setForceUpdate( repositoryRequest.isForceUpdate() ); } public boolean isOffline() @@ -72,6 +75,18 @@ public class DefaultRepositoryRequest return this; } + public boolean isForceUpdate() + { + return forceUpdate; + } + + public DefaultRepositoryRequest setForceUpdate( boolean forceUpdate ) + { + this.forceUpdate = forceUpdate; + + return this; + } + public ArtifactRepository getLocalRepository() { return localRepository; diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/RepositoryRequest.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/RepositoryRequest.java index b395c60444..74f8e2765b 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/RepositoryRequest.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/repository/RepositoryRequest.java @@ -44,6 +44,24 @@ public interface RepositoryRequest */ RepositoryRequest setOffline( boolean offline ); + /** + * Indicates whether remote repositories should be re-checked for updated artifacts/metadata regardless of their + * configured update policy. + * + * @return {@code true} if remote repositories should be re-checked for updated artifacts/metadata, {@code false} + * otherwise. + */ + boolean isForceUpdate(); + + /** + * Enables/disabled forced checks for updated artifacts/metadata on remote repositories. + * + * @param forceUpdate {@code true} to forcibly check the remote repositories for updated artifacts/metadata, {@code + * false} to use the update policy configured on each repository. + * @return This request, never {@code null}. + */ + RepositoryRequest setForceUpdate( boolean forceUpdate ); + /** * Gets the local repository to use. * diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java index a95eb3f0d3..f1d5215958 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java @@ -117,7 +117,8 @@ public class DefaultRepositoryMetadataManager new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( metadata, repository ) ); - if ( updateCheckManager.isUpdateRequired( metadata, repository, file ) ) + if ( ( policy.isEnabled() && request.isForceUpdate() ) + || updateCheckManager.isUpdateRequired( metadata, repository, file ) ) { getLogger().info( metadata.getKey() + ": checking for updates from " + repository.getId() ); try diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java index 08a14059f9..d2c1398805 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java @@ -72,6 +72,8 @@ public class ArtifactResolutionRequest private boolean offline; + private boolean forceUpdate; + public ArtifactResolutionRequest() { // nothing here @@ -83,6 +85,7 @@ public class ArtifactResolutionRequest setRemoteRepositories( request.getRemoteRepositories() ); setCache( request.getCache() ); setOffline( request.isOffline() ); + setForceUpdate( request.isForceUpdate() ); } public Artifact getArtifact() @@ -272,4 +275,16 @@ public class ArtifactResolutionRequest return this; } + public boolean isForceUpdate() + { + return forceUpdate; + } + + public ArtifactResolutionRequest setForceUpdate( boolean forceUpdate ) + { + this.forceUpdate = forceUpdate; + + return this; + } + } diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/metadata/DefaultMetadataResolutionRequest.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/metadata/DefaultMetadataResolutionRequest.java index 54959d2ac9..904a24d260 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/metadata/DefaultMetadataResolutionRequest.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/metadata/DefaultMetadataResolutionRequest.java @@ -124,4 +124,16 @@ public class DefaultMetadataResolutionRequest return this; } + public boolean isForceUpdate() + { + return repositoryRequest.isForceUpdate(); + } + + public DefaultMetadataResolutionRequest setForceUpdate( boolean forceUpdate ) + { + repositoryRequest.setForceUpdate( forceUpdate ); + + return this; + } + } diff --git a/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java index e302e1d9ba..e34e9ed985 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java @@ -133,6 +133,7 @@ public class DefaultProjectDependenciesResolver .setResolutionFilter( resolutionScopeFilter ) .setLocalRepository( session.getLocalRepository() ) .setOffline( session.isOffline() ) + .setForceUpdate( session.getRequest().isUpdateSnapshots() ) .setCache( session.getRepositoryCache() ); // FIXME setTransferListener diff --git a/maven-core/src/main/java/org/apache/maven/plugin/prefix/DefaultPluginPrefixRequest.java b/maven-core/src/main/java/org/apache/maven/plugin/prefix/DefaultPluginPrefixRequest.java index f397301ebc..d3cdb65d4d 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/prefix/DefaultPluginPrefixRequest.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/prefix/DefaultPluginPrefixRequest.java @@ -164,4 +164,16 @@ public class DefaultPluginPrefixRequest return this; } + public boolean isForceUpdate() + { + return repositoryRequest.isForceUpdate(); + } + + public DefaultPluginPrefixRequest setForceUpdate( boolean forceUpdate ) + { + repositoryRequest.setForceUpdate( forceUpdate ); + + return this; + } + } diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java b/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java index bd470cbd21..0eb7fa61d2 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java @@ -131,4 +131,16 @@ public class DefaultPluginVersionRequest return this; } + public boolean isForceUpdate() + { + return repositoryRequest.isForceUpdate(); + } + + public DefaultPluginVersionRequest setForceUpdate( boolean forceUpdate ) + { + repositoryRequest.setForceUpdate( forceUpdate ); + + return this; + } + } diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java index 4032d72d20..e5dc244f63 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java @@ -133,6 +133,7 @@ public class DefaultProjectBuilder .setLocalRepository( configuration.getLocalRepository() ) .setRemoteRepositories( project.getRemoteArtifactRepositories() ) .setOffline( configuration.isOffline() ) + .setForceUpdate( configuration.isForceUpdate() ) .setManagedVersionMap( project.getManagedVersionMap() ); // FIXME setTransferListener @@ -195,7 +196,8 @@ public class DefaultProjectBuilder .setCache( configuration.getRepositoryCache() ) .setLocalRepository( configuration.getLocalRepository() ) .setRemoteRepositories( configuration.getRemoteRepositories() ) - .setOffline( configuration.isOffline() ); + .setOffline( configuration.isOffline() ) + .setForceUpdate( configuration.isForceUpdate() ); // FIXME setTransferListener ArtifactResolutionResult result = repositorySystem.resolve( request ); diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java index fdcab08c24..8259c92fb6 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java @@ -39,6 +39,8 @@ public class DefaultProjectBuildingRequest private boolean offline; + private boolean forceUpdate; + private RepositoryCache repositoryCache; private ArtifactRepository localRepository; @@ -112,6 +114,18 @@ public class DefaultProjectBuildingRequest return offline; } + public boolean isForceUpdate() + { + return forceUpdate; + } + + public ProjectBuildingRequest setForceUpdate( boolean forceUpdate ) + { + this.forceUpdate = forceUpdate; + + return this; + } + public ProjectBuildingRequest setRepositoryCache( RepositoryCache repositoryCache ) { this.repositoryCache = repositoryCache; diff --git a/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java b/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java index 8e6fbec269..e6ea14cdf7 100644 --- a/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java +++ b/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java @@ -38,6 +38,10 @@ public interface ProjectBuildingRequest boolean isOffline(); + ProjectBuildingRequest setForceUpdate( boolean forceUpdate ); + + boolean isForceUpdate(); + ProjectBuildingRequest setRepositoryCache( RepositoryCache repositoryCache ); RepositoryCache getRepositoryCache(); diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java index 47ea760717..fe578caca3 100644 --- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java +++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java @@ -525,6 +525,7 @@ public class MavenMetadataSource configuration.setLocalRepository( repositoryRequest.getLocalRepository() ); configuration.setRemoteRepositories( repositoryRequest.getRemoteRepositories() ); configuration.setOffline( repositoryRequest.isOffline() ); + configuration.setForceUpdate( repositoryRequest.isForceUpdate() ); configuration.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL ); configuration.setProcessPlugins( false ); configuration.setSystemProperties( System.getProperties() );