mirror of https://github.com/apache/maven.git
[MNG-7349] Limit relocation warning message to direct dependencies only
# Conflicts: # maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
This commit is contained in:
parent
dbfe8097d2
commit
6b607109d3
|
@ -113,6 +113,18 @@ public class DefaultPluginDependenciesResolver
|
|||
|
||||
pluginArtifact = result.getArtifact();
|
||||
|
||||
if ( logger.isWarnEnabled() )
|
||||
{
|
||||
if ( !result.getRelocations().isEmpty() )
|
||||
{
|
||||
String message = pluginArtifact instanceof org.apache.maven.repository.internal.RelocatedArtifact
|
||||
? ( ( org.apache.maven.repository.internal.RelocatedArtifact ) pluginArtifact ).getMessage()
|
||||
: null;
|
||||
logger.warn( "The artifact " + result.getRelocations().get( 0 ) + " has been relocated to "
|
||||
+ pluginArtifact + ( message != null ? ": " + message : "" ) );
|
||||
}
|
||||
}
|
||||
|
||||
String requiredMavenVersion = (String) result.getProperties().get( "prerequisites.maven" );
|
||||
if ( requiredMavenVersion != null )
|
||||
{
|
||||
|
|
|
@ -188,6 +188,22 @@ public class DefaultProjectDependenciesResolver
|
|||
|
||||
depRequest.setRoot( node );
|
||||
|
||||
if ( logger.isWarnEnabled() )
|
||||
{
|
||||
for ( DependencyNode child : node.getChildren() )
|
||||
{
|
||||
if ( !child.getRelocations().isEmpty() )
|
||||
{
|
||||
org.eclipse.aether.artifact.Artifact relocated = child.getDependency().getArtifact();
|
||||
String message = relocated instanceof org.apache.maven.repository.internal.RelocatedArtifact
|
||||
? ( ( org.apache.maven.repository.internal.RelocatedArtifact ) relocated ).getMessage()
|
||||
: null;
|
||||
logger.warn( "The artifact " + child.getRelocations().get( 0 ) + " has been relocated to "
|
||||
+ relocated + ( message != null ? ": " + message : "" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( logger.isDebugEnabled() )
|
||||
{
|
||||
node.accept( new GraphLogger( project ) );
|
||||
|
|
|
@ -261,20 +261,10 @@ public class DefaultArtifactDescriptorReader implements ArtifactDescriptorReader
|
|||
if ( relocation != null )
|
||||
{
|
||||
result.addRelocation( a );
|
||||
Artifact relocatedArtifact =
|
||||
a =
|
||||
new RelocatedArtifact( a, relocation.getGroupId(), relocation.getArtifactId(),
|
||||
relocation.getVersion() );
|
||||
if ( LOGGER.isWarnEnabled() )
|
||||
{
|
||||
String message = "The artifact " + a + " has been relocated to " + relocatedArtifact;
|
||||
if ( relocation.getMessage() != null )
|
||||
{
|
||||
message += ": " + relocation.getMessage();
|
||||
}
|
||||
LOGGER.warn( message );
|
||||
}
|
||||
result.setArtifact( relocatedArtifact );
|
||||
a = relocatedArtifact;
|
||||
relocation.getVersion(), relocation.getMessage() );
|
||||
result.setArtifact( a );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.eclipse.aether.artifact.Artifact;
|
|||
/**
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
final class RelocatedArtifact
|
||||
public final class RelocatedArtifact
|
||||
extends AbstractArtifact
|
||||
{
|
||||
|
||||
|
@ -41,13 +41,16 @@ final class RelocatedArtifact
|
|||
|
||||
private final String version;
|
||||
|
||||
RelocatedArtifact( Artifact artifact, String groupId, String artifactId, String version )
|
||||
private final String message;
|
||||
|
||||
RelocatedArtifact( Artifact artifact, String groupId, String artifactId, String version, String message )
|
||||
{
|
||||
this.artifact = Objects.requireNonNull( artifact, "artifact cannot be null" );
|
||||
// TODO Use StringUtils here
|
||||
this.groupId = ( groupId != null && groupId.length() > 0 ) ? groupId : null;
|
||||
this.artifactId = ( artifactId != null && artifactId.length() > 0 ) ? artifactId : null;
|
||||
this.version = ( version != null && version.length() > 0 ) ? version : null;
|
||||
this.message = ( message != null && message.length() > 0 ) ? message : null;
|
||||
}
|
||||
|
||||
public String getGroupId()
|
||||
|
@ -95,7 +98,7 @@ final class RelocatedArtifact
|
|||
{
|
||||
return this;
|
||||
}
|
||||
return new RelocatedArtifact( artifact, groupId, artifactId, version );
|
||||
return new RelocatedArtifact( artifact, groupId, artifactId, version, message );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -106,7 +109,7 @@ final class RelocatedArtifact
|
|||
{
|
||||
return this;
|
||||
}
|
||||
return new RelocatedArtifact( artifact.setFile( file ), groupId, artifactId, version );
|
||||
return new RelocatedArtifact( artifact.setFile( file ), groupId, artifactId, version, message );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -117,7 +120,7 @@ final class RelocatedArtifact
|
|||
{
|
||||
return this;
|
||||
}
|
||||
return new RelocatedArtifact( artifact.setProperties( properties ), groupId, artifactId, version );
|
||||
return new RelocatedArtifact( artifact.setProperties( properties ), groupId, artifactId, version, message );
|
||||
}
|
||||
|
||||
public String getClassifier()
|
||||
|
@ -145,4 +148,8 @@ final class RelocatedArtifact
|
|||
return artifact.getProperties();
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue