mirror of https://github.com/apache/maven.git
[MNG-4554] [regression] plugin updates are requested on every build regardless of policies
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@905424 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8b6616cf3b
commit
1df9413fd4
|
@ -21,6 +21,7 @@ package org.apache.maven.plugin.prefix.internal;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -68,6 +69,8 @@ public class DefaultPluginPrefixResolver
|
||||||
public PluginPrefixResult resolve( PluginPrefixRequest request )
|
public PluginPrefixResult resolve( PluginPrefixRequest request )
|
||||||
throws NoPluginFoundForPrefixException
|
throws NoPluginFoundForPrefixException
|
||||||
{
|
{
|
||||||
|
logger.debug( "Resolving plugin prefix " + request.getPrefix() + " from " + request.getPluginGroups() );
|
||||||
|
|
||||||
PluginPrefixResult result = resolveFromProject( request );
|
PluginPrefixResult result = resolveFromProject( request );
|
||||||
|
|
||||||
if ( result == null )
|
if ( result == null )
|
||||||
|
@ -80,6 +83,17 @@ public class DefaultPluginPrefixResolver
|
||||||
request.getLocalRepository(),
|
request.getLocalRepository(),
|
||||||
request.getRemoteRepositories() );
|
request.getRemoteRepositories() );
|
||||||
}
|
}
|
||||||
|
else if ( logger.isDebugEnabled() )
|
||||||
|
{
|
||||||
|
logger.debug( "Resolved plugin prefix " + request.getPrefix() + " to " + result.getGroupId() + ":"
|
||||||
|
+ result.getArtifactId() + " from repository "
|
||||||
|
+ ( result.getRepository() != null ? result.getRepository().getId() : "null" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( logger.isDebugEnabled() )
|
||||||
|
{
|
||||||
|
logger.debug( "Resolved plugin prefix " + request.getPrefix() + " to " + result.getGroupId() + ":"
|
||||||
|
+ result.getArtifactId() + " from POM " + request.getPom() );
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -142,12 +156,12 @@ public class DefaultPluginPrefixResolver
|
||||||
//
|
//
|
||||||
for ( String pluginGroup : request.getPluginGroups() )
|
for ( String pluginGroup : request.getPluginGroups() )
|
||||||
{
|
{
|
||||||
String localPath =
|
String localPath = getLocalMetadataPath( pluginGroup, localRepository );
|
||||||
pluginGroup.replace( '.', '/' ) + "/" + "maven-metadata-" + localRepository.getId() + ".xml";
|
|
||||||
|
|
||||||
File destination = new File( localRepository.getBasedir(), localPath );
|
File groupMetadataFile = new File( localRepository.getBasedir(), localPath );
|
||||||
|
|
||||||
PluginPrefixResult result = resolveFromRepository( request, pluginGroup, destination, localRepository );
|
PluginPrefixResult result =
|
||||||
|
resolveFromRepository( request, pluginGroup, groupMetadataFile, localRepository );
|
||||||
|
|
||||||
if ( result != null )
|
if ( result != null )
|
||||||
{
|
{
|
||||||
|
@ -155,24 +169,26 @@ public class DefaultPluginPrefixResolver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<ArtifactRepository> recheck = new ArrayList<ArtifactRepository>();
|
||||||
|
|
||||||
// Process all the remote repositories.
|
// Process all the remote repositories.
|
||||||
//
|
//
|
||||||
for ( String pluginGroup : request.getPluginGroups() )
|
for ( String pluginGroup : request.getPluginGroups() )
|
||||||
{
|
{
|
||||||
for ( ArtifactRepository repository : request.getRemoteRepositories() )
|
for ( ArtifactRepository repository : request.getRemoteRepositories() )
|
||||||
{
|
{
|
||||||
String localPath =
|
String localPath = getLocalMetadataPath( pluginGroup, repository );
|
||||||
pluginGroup.replace( '.', '/' ) + "/" + "maven-metadata-" + repository.getId() + ".xml";
|
|
||||||
|
|
||||||
File destination = new File( localRepository.getBasedir(), localPath );
|
File groupMetadataFile = new File( localRepository.getBasedir(), localPath );
|
||||||
|
|
||||||
if ( !request.isOffline() )
|
if ( !request.isOffline() && ( !groupMetadataFile.exists() || request.isForceUpdate() ) )
|
||||||
{
|
{
|
||||||
String remotePath = pluginGroup.replace( '.', '/' ) + "/" + "maven-metadata.xml";
|
String remotePath = getRemoteMetadataPath( pluginGroup, repository );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
repositorySystem.retrieve( repository, destination, remotePath, request.getTransferListener() );
|
repositorySystem.retrieve( repository, groupMetadataFile, remotePath,
|
||||||
|
request.getTransferListener() );
|
||||||
}
|
}
|
||||||
catch ( ArtifactTransferFailedException e )
|
catch ( ArtifactTransferFailedException e )
|
||||||
{
|
{
|
||||||
|
@ -190,8 +206,53 @@ public class DefaultPluginPrefixResolver
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ( !request.isOffline() && !request.isForceUpdate() )
|
||||||
|
{
|
||||||
|
recheck.add( repository );
|
||||||
|
}
|
||||||
|
|
||||||
PluginPrefixResult result = resolveFromRepository( request, pluginGroup, destination, repository );
|
PluginPrefixResult result = resolveFromRepository( request, pluginGroup, groupMetadataFile, repository );
|
||||||
|
|
||||||
|
if ( result != null )
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retry the remote repositories for which we previously only consulted the possibly outdated local cache.
|
||||||
|
//
|
||||||
|
for ( String pluginGroup : request.getPluginGroups() )
|
||||||
|
{
|
||||||
|
for ( ArtifactRepository repository : recheck )
|
||||||
|
{
|
||||||
|
String localPath = getLocalMetadataPath( pluginGroup, repository );
|
||||||
|
|
||||||
|
File groupMetadataFile = new File( localRepository.getBasedir(), localPath );
|
||||||
|
|
||||||
|
String remotePath = getRemoteMetadataPath( pluginGroup, repository );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
repositorySystem.retrieve( repository, groupMetadataFile, remotePath, request.getTransferListener() );
|
||||||
|
}
|
||||||
|
catch ( ArtifactTransferFailedException e )
|
||||||
|
{
|
||||||
|
if ( logger.isDebugEnabled() )
|
||||||
|
{
|
||||||
|
logger.warn( "Failed to retrieve " + remotePath + ": " + e.getMessage(), e );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.warn( "Failed to retrieve " + remotePath + ": " + e.getMessage() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( ArtifactDoesNotExistException e )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginPrefixResult result = resolveFromRepository( request, pluginGroup, groupMetadataFile, repository );
|
||||||
|
|
||||||
if ( result != null )
|
if ( result != null )
|
||||||
{
|
{
|
||||||
|
@ -243,4 +304,14 @@ public class DefaultPluginPrefixResolver
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getLocalMetadataPath( String groupId, ArtifactRepository repository )
|
||||||
|
{
|
||||||
|
return groupId.replace( '.', '/' ) + "/" + "maven-metadata-" + repository.getId() + ".xml";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getRemoteMetadataPath( String groupId, ArtifactRepository repository )
|
||||||
|
{
|
||||||
|
return groupId.replace( '.', '/' ) + "/" + "maven-metadata.xml";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue