Skip to content

Commit

Permalink
[MNG-7253] Display relocation message defined in model
Browse files Browse the repository at this point in the history
Move logging to DefaultArtifactDescriptorReader

This closes #544
  • Loading branch information
gastaldi authored and michael-o committed Sep 18, 2021
1 parent 8c66edc commit ab54d17
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,6 @@ public DependencyResolutionResult resolve( DependencyResolutionRequest request )

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 ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
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
Expand All @@ -77,6 +79,8 @@
public class DefaultArtifactDescriptorReader
implements ArtifactDescriptorReader, Service
{
private static final Logger LOGGER = LoggerFactory.getLogger( DefaultArtifactDescriptorReader.class );

private RemoteRepositoryManager remoteRepositoryManager;

private VersionResolver versionResolver;
Expand Down Expand Up @@ -316,10 +320,20 @@ private Model loadPom( RepositorySystemSession session, ArtifactDescriptorReques
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
{
Expand Down

0 comments on commit ab54d17

Please sign in to comment.