diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java index 95b642f657..73c6d24ebb 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java @@ -960,6 +960,7 @@ public class DefaultLifecycleExecutor request.setRemoteRepositories( project.getPluginArtifactRepositories() ); } request.setOffline( session.isOffline() ); + request.setForceUpdate( session.getRequest().isUpdateSnapshots() ); request.setTransferListener( session.getRequest().getTransferListener() ); return request; diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java index e28c51b5cb..e28a57a89e 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java @@ -44,17 +44,22 @@ public class DefaultExtensionRealmCache private final List files; + private final List ids; + private final int hashCode; public CacheKey( List extensionArtifacts ) { this.files = new ArrayList( extensionArtifacts.size() ); + this.ids = new ArrayList( extensionArtifacts.size() ); + for ( Artifact artifact : extensionArtifacts ) { files.add( artifact.getFile() ); + ids.add( artifact.getVersion() ); } - this.hashCode = files.hashCode(); + this.hashCode = files.hashCode() * 31 + ids.hashCode(); } @Override @@ -78,7 +83,7 @@ public class DefaultExtensionRealmCache CacheKey other = (CacheKey) o; - return files.equals( other.files ); + return files.equals( other.files ) && ids.equals( other.ids ); } } diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java index 99c111e60f..a2f43de467 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java @@ -21,11 +21,13 @@ package org.apache.maven.plugin; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.MojoDescriptor; @@ -144,7 +146,7 @@ public class DefaultPluginDescriptorCache hash = hash * 31 + groupId.hashCode(); hash = hash * 31 + artifactId.hashCode(); hash = hash * 31 + version.hashCode(); - hash = hash * 31 + repositories.hashCode(); + hash = hash * 31 + repositoriesHashCode( repositories ); this.hashCode = hash; } @@ -170,7 +172,7 @@ public class DefaultPluginDescriptorCache CacheKey that = (CacheKey) obj; return this.artifactId.equals( that.artifactId ) && this.groupId.equals( that.groupId ) - && this.version.equals( that.version ) && this.repositories.equals( that.repositories ); + && this.version.equals( that.version ) && repositoriesEquals( this.repositories, that.repositories ); } @Override @@ -179,6 +181,68 @@ public class DefaultPluginDescriptorCache return groupId + ':' + artifactId + ':' + version; } + private static int repositoryHashCode( ArtifactRepository repository ) + { + int result = 17; + result = 31 * result + ( repository.getId() != null ? repository.getId().hashCode() : 0 ); + return result; + } + + private static int repositoriesHashCode( List repositories ) + { + int result = 17; + for ( ArtifactRepository repository : repositories ) + { + result = 31 * result + repositoryHashCode( repository ); + } + return result; + } + + private static boolean repositoryEquals( ArtifactRepository r1, ArtifactRepository r2 ) + { + if ( r1 == r2 ) + { + return true; + } + + return eq( r1.getId(), r2.getId() ) && eq( r1.getUrl(), r2.getUrl() ) + && repositoryPolicyEquals( r1.getReleases(), r2.getReleases() ) + && repositoryPolicyEquals( r1.getSnapshots(), r2.getSnapshots() ); + } + + private static boolean repositoryPolicyEquals( ArtifactRepositoryPolicy p1, ArtifactRepositoryPolicy p2 ) + { + if ( p1 == p2 ) + { + return true; + } + + return p1.isEnabled() == p2.isEnabled() && eq( p1.getUpdatePolicy(), p2.getUpdatePolicy() ); + } + + private static boolean repositoriesEquals( List r1, List r2 ) + { + if ( r1.size() != r2.size() ) + { + return false; + } + + for ( Iterator it1 = r1.iterator(), it2 = r2.iterator(); it1.hasNext(); ) + { + if ( !repositoryEquals( it1.next(), it2.next() ) ) + { + return false; + } + } + + return true; + } + + private static boolean eq( T s1, T s2 ) + { + return s1 != null ? s1.equals( s2 ) : s2 == null; + } + } } diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java index 101aa0afd3..fcc850b0f2 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java @@ -344,6 +344,7 @@ public class DefaultMavenPluginManager request.setRemoteRepositories( project.getPluginArtifactRepositories() ); request.setCache( session.getRepositoryCache() ); request.setOffline( session.isOffline() ); + request.setForceUpdate( session.getRequest().isUpdateSnapshots() ); request.setTransferListener( session.getRequest().getTransferListener() ); ArtifactFilter dependencyFilter = project.getExtensionArtifactFilter(); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginManager.java index b654a6fd90..35b169d222 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginManager.java @@ -96,6 +96,8 @@ public class DefaultPluginManager request.setRemoteRepositories( project.getPluginArtifactRepositories() ); } request.setOffline( session.isOffline() ); + request.setForceUpdate( session.getRequest().isUpdateSnapshots() ); + request.setTransferListener( session.getRequest().getTransferListener() ); return request; } 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 1a582666ed..a7d349642a 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 @@ -83,6 +83,7 @@ public class DefaultPluginPrefixRequest setCache( session.getRepositoryCache() ); setLocalRepository( session.getLocalRepository() ); setOffline( session.isOffline() ); + setForceUpdate( session.getRequest().isUpdateSnapshots() ); setTransferListener( session.getRequest().getTransferListener() ); MavenProject project = session.getCurrentProject(); 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 ee1f916971..77c466e29c 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 @@ -92,6 +92,7 @@ public class DefaultPluginVersionRequest setCache( session.getRepositoryCache() ); setLocalRepository( session.getLocalRepository() ); setOffline( session.isOffline() ); + setForceUpdate( session.getRequest().isUpdateSnapshots() ); setTransferListener( session.getRequest().getTransferListener() ); MavenProject project = session.getCurrentProject(); diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java b/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java index 7070b009a6..b248d05202 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java @@ -110,6 +110,8 @@ class DefaultModelBuildingListener repositoryRequest.setLocalRepository( projectBuildingRequest.getLocalRepository() ); repositoryRequest.setRemoteRepositories( pluginRepositories ); repositoryRequest.setOffline( projectBuildingRequest.isOffline() ); + repositoryRequest.setForceUpdate( projectBuildingRequest.isForceUpdate() ); + repositoryRequest.setTransferListener( projectBuildingRequest.getTransferListener() ); ProjectRealmCache.CacheRecord record = projectBuildingHelper.createProjectRealm( project, model, repositoryRequest );