mirror of https://github.com/apache/maven.git
[MNG-4482] [regression] command line option "-update-snapshots" does not work for plugins/extensions
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@887367 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
506b7c6334
commit
9be3468e26
|
@ -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;
|
||||
|
|
|
@ -44,17 +44,22 @@ public class DefaultExtensionRealmCache
|
|||
|
||||
private final List<File> files;
|
||||
|
||||
private final List<String> ids;
|
||||
|
||||
private final int hashCode;
|
||||
|
||||
public CacheKey( List<? extends Artifact> extensionArtifacts )
|
||||
{
|
||||
this.files = new ArrayList<File>( extensionArtifacts.size() );
|
||||
this.ids = new ArrayList<String>( 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 );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<ArtifactRepository> 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<ArtifactRepository> r1, List<ArtifactRepository> r2 )
|
||||
{
|
||||
if ( r1.size() != r2.size() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( Iterator<ArtifactRepository> it1 = r1.iterator(), it2 = r2.iterator(); it1.hasNext(); )
|
||||
{
|
||||
if ( !repositoryEquals( it1.next(), it2.next() ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static <T> boolean eq( T s1, T s2 )
|
||||
{
|
||||
return s1 != null ? s1.equals( s2 ) : s2 == null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue