[MNG-7253] Display relocation message defined in model

Move logging to DefaultArtifactDescriptorReader

This closes #543
This commit is contained in:
George Gastaldi 2021-09-17 12:18:27 -03:00 committed by Michael Osipov
parent 8c297e93a3
commit a1ba33069f
2 changed files with 16 additions and 14 deletions

View File

@ -184,18 +184,6 @@ public class DefaultProjectDependenciesResolver
depRequest.setRoot( node );
if ( logger.isWarnEnabled() )
{
for ( DependencyNode child : node.getChildren() )
{
if ( !child.getRelocations().isEmpty() )
{
logger.warn( "The artifact " + child.getRelocations().get( 0 ) + " has been relocated to "
+ child.getDependency().getArtifact() );
}
}
}
if ( logger.isDebugEnabled() )
{
node.accept( new GraphLogger( project ) );

View File

@ -68,6 +68,8 @@ import org.eclipse.aether.resolution.VersionResult;
import org.eclipse.aether.spi.locator.Service;
import org.eclipse.aether.spi.locator.ServiceLocator;
import org.eclipse.aether.transfer.ArtifactNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Benjamin Bentmann
@ -77,6 +79,8 @@ import org.eclipse.aether.transfer.ArtifactNotFoundException;
public class DefaultArtifactDescriptorReader
implements ArtifactDescriptorReader, Service
{
private static final Logger LOGGER = LoggerFactory.getLogger( DefaultArtifactDescriptorReader.class );
private RemoteRepositoryManager remoteRepositoryManager;
private VersionResolver versionResolver;
@ -319,10 +323,20 @@ public class DefaultArtifactDescriptorReader
if ( relocation != null )
{
result.addRelocation( a );
a =
Artifact relocatedArtifact =
new RelocatedArtifact( a, relocation.getGroupId(), relocation.getArtifactId(),
relocation.getVersion() );
result.setArtifact( a );
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;
}
else
{