mirror of https://github.com/apache/maven.git
PR: MNG-616
improve version logging, use artifact.toString for textual logging git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@307309 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ce8f50cc0a
commit
f8cbb08498
|
@ -18,6 +18,7 @@ package org.apache.maven.artifact.ant;
|
|||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.resolver.ResolutionListener;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
import org.apache.tools.ant.Project;
|
||||
|
||||
/**
|
||||
|
@ -54,39 +55,45 @@ public class AntResolutionListener
|
|||
|
||||
public void includeArtifact( Artifact artifact )
|
||||
{
|
||||
project.log( indent + artifact.getId() + " (selected)" );
|
||||
project.log( indent + artifact + " (selected)" );
|
||||
}
|
||||
|
||||
public void omitForNearer( Artifact omitted, Artifact kept )
|
||||
{
|
||||
project.log( indent + omitted.getId() + " (removed - nearer found: " + kept.getVersion() + ")" );
|
||||
project.log( indent + omitted + " (removed - nearer found: " + kept.getVersion() + ")" );
|
||||
}
|
||||
|
||||
public void omitForCycle( Artifact omitted )
|
||||
{
|
||||
project.log( indent + omitted.getId() + " (removed - causes a cycle in the graph)" );
|
||||
project.log( indent + omitted + " (removed - causes a cycle in the graph)" );
|
||||
}
|
||||
|
||||
public void updateScope( Artifact artifact, String scope )
|
||||
{
|
||||
project.log( indent + artifact.getId() + " (setting scope to: " + scope + ")" );
|
||||
project.log( indent + artifact + " (setting scope to: " + scope + ")" );
|
||||
}
|
||||
|
||||
public void updateScopeCurrentPom( Artifact artifact, String scope )
|
||||
{
|
||||
project.log( indent + artifact.getId() + " (not setting scope to: " + scope + "; local scope " +
|
||||
artifact.getScope() + " wins)" );
|
||||
project.log( indent + artifact + " (not setting scope to: " + scope + "; local scope " + artifact.getScope() +
|
||||
" wins)" );
|
||||
}
|
||||
|
||||
public void selectVersionFromRange( Artifact artifact )
|
||||
{
|
||||
project.log( indent + artifact.getId() + " (setting version to: " + artifact.getVersion() + " from range: " +
|
||||
project.log( indent + artifact + " (setting version to: " + artifact.getVersion() + " from range: " +
|
||||
artifact.getVersionRange() + ")" );
|
||||
}
|
||||
|
||||
public void restrictRange( Artifact artifact, Artifact replacement, VersionRange newRange )
|
||||
{
|
||||
project.log( indent + artifact + " (range restricted from: " + artifact.getVersionRange() + " and: " +
|
||||
replacement.getVersionRange() + " to: " + newRange + " )" );
|
||||
}
|
||||
|
||||
public void manageArtifact( Artifact artifact, Artifact replacement )
|
||||
{
|
||||
String msg = indent + artifact.getId();
|
||||
String msg = indent + artifact;
|
||||
msg += " (";
|
||||
if ( replacement.getVersion() != null )
|
||||
{
|
||||
|
|
|
@ -59,7 +59,7 @@ public class DefaultArtifactDeployer
|
|||
{
|
||||
if ( !wagonManager.isOnline() )
|
||||
{
|
||||
getLogger().warn( "System is offline. Cannot deploy artifact: " + artifact.getId() + "." );
|
||||
getLogger().warn( "System is offline. Cannot deploy artifact: " + artifact + "." );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.apache.maven.artifact.resolver;
|
|||
*/
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
||||
/**
|
||||
|
@ -53,39 +54,45 @@ public class DebugResolutionListener
|
|||
|
||||
public void includeArtifact( Artifact artifact )
|
||||
{
|
||||
logger.debug( indent + artifact.getId() + " (selected for " + artifact.getScope() + ")" );
|
||||
logger.debug( indent + artifact + " (selected for " + artifact.getScope() + ")" );
|
||||
}
|
||||
|
||||
public void omitForNearer( Artifact omitted, Artifact kept )
|
||||
{
|
||||
logger.debug( indent + omitted.getId() + " (removed - nearer found: " + kept.getVersion() + ")" );
|
||||
logger.debug( indent + omitted + " (removed - nearer found: " + kept.getVersion() + ")" );
|
||||
}
|
||||
|
||||
public void omitForCycle( Artifact omitted )
|
||||
{
|
||||
logger.debug( indent + omitted.getId() + " (removed - causes a cycle in the graph)" );
|
||||
logger.debug( indent + omitted + " (removed - causes a cycle in the graph)" );
|
||||
}
|
||||
|
||||
public void updateScopeCurrentPom( Artifact artifact, String scope )
|
||||
{
|
||||
logger.debug( indent + artifact.getId() + " (not setting scope to: " + scope + "; local scope " +
|
||||
artifact.getScope() + " wins)" );
|
||||
logger.debug( indent + artifact + " (not setting scope to: " + scope + "; local scope " + artifact.getScope() +
|
||||
" wins)" );
|
||||
}
|
||||
|
||||
public void updateScope( Artifact artifact, String scope )
|
||||
{
|
||||
logger.debug( indent + artifact.getId() + " (setting scope to: " + scope + ")" );
|
||||
logger.debug( indent + artifact + " (setting scope to: " + scope + ")" );
|
||||
}
|
||||
|
||||
public void selectVersionFromRange( Artifact artifact )
|
||||
{
|
||||
logger.debug( indent + artifact.getId() + " (setting version to: " + artifact.getVersion() + " from range: " +
|
||||
logger.debug( indent + artifact + " (setting version to: " + artifact.getVersion() + " from range: " +
|
||||
artifact.getVersionRange() + ")" );
|
||||
}
|
||||
|
||||
public void restrictRange( Artifact artifact, Artifact replacement, VersionRange newRange )
|
||||
{
|
||||
logger.debug( indent + artifact + " (range restricted from: " + artifact.getVersionRange() + " and: " +
|
||||
replacement.getVersionRange() + " to: " + newRange + " )" );
|
||||
}
|
||||
|
||||
public void manageArtifact( Artifact artifact, Artifact replacement )
|
||||
{
|
||||
String msg = indent + artifact.getId();
|
||||
String msg = indent + artifact;
|
||||
msg += " (";
|
||||
if ( replacement.getVersion() != null )
|
||||
{
|
||||
|
|
|
@ -83,7 +83,7 @@ public class DefaultArtifactResolver
|
|||
if ( !systemFile.exists() )
|
||||
{
|
||||
throw new ArtifactNotFoundException(
|
||||
"System artifact: " + artifact.getId() + " not found in path: " + systemFile, artifact );
|
||||
"System artifact: " + artifact + " not found in path: " + systemFile, artifact );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -117,7 +117,7 @@ public class DefaultArtifactResolver
|
|||
{
|
||||
if ( !wagonManager.isOnline() )
|
||||
{
|
||||
getLogger().debug( "System is offline. Cannot resolve artifact: " + artifact.getId() + "." );
|
||||
getLogger().debug( "System is offline. Cannot resolve artifact: " + artifact + "." );
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.apache.maven.artifact.resolver;
|
|||
*/
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
@ -69,7 +70,7 @@ public class WarningResolutionListener
|
|||
// TODO: better way than static? this might hide messages in a reactor
|
||||
if ( !ignoredArtifacts.contains( artifact ) )
|
||||
{
|
||||
logger.warn( "\n\tArtifact " + artifact.getId() + " retains local scope '" + artifact.getScope() +
|
||||
logger.warn( "\n\tArtifact " + artifact + " retains local scope '" + artifact.getScope() +
|
||||
"' overriding broader scope '" + scope + "'\n" +
|
||||
"\tgiven by a dependency. If this is not intended, modify or remove the local scope.\n" );
|
||||
ignoredArtifacts.add( artifact );
|
||||
|
@ -87,4 +88,8 @@ public class WarningResolutionListener
|
|||
public void selectVersionFromRange( Artifact artifact )
|
||||
{
|
||||
}
|
||||
|
||||
public void restrictRange( Artifact artifact, Artifact replacement, VersionRange newRange )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,7 +148,14 @@ public class DefaultArtifactCollector
|
|||
{
|
||||
// TODO: shouldn't need to double up on this work, only done for simplicity of handling recommended
|
||||
// version but the restriction is identical
|
||||
previous.getArtifact().setVersionRange( previousRange.restrict( currentRange ) );
|
||||
VersionRange newRange = previousRange.restrict( currentRange );
|
||||
// TODO: ick. this forces the OCE that should have come from the previous call. It is still correct
|
||||
if ( newRange.isSelectedVersionKnown( previous.getArtifact() ) )
|
||||
{
|
||||
fireEvent( ResolutionListener.RESTRICT_RANGE, listeners, node, previous.getArtifact(),
|
||||
newRange );
|
||||
}
|
||||
previous.getArtifact().setVersionRange( newRange );
|
||||
node.getArtifact().setVersionRange( currentRange.restrict( previousRange ) );
|
||||
}
|
||||
|
||||
|
@ -317,6 +324,12 @@ public class DefaultArtifactCollector
|
|||
}
|
||||
|
||||
private void fireEvent( int event, List listeners, ResolutionNode node, Artifact replacement )
|
||||
{
|
||||
fireEvent( event, listeners, node, replacement, null );
|
||||
}
|
||||
|
||||
private void fireEvent( int event, List listeners, ResolutionNode node, Artifact replacement,
|
||||
VersionRange newRange )
|
||||
{
|
||||
for ( Iterator i = listeners.iterator(); i.hasNext(); )
|
||||
{
|
||||
|
@ -337,7 +350,12 @@ public class DefaultArtifactCollector
|
|||
listener.includeArtifact( node.getArtifact() );
|
||||
break;
|
||||
case ResolutionListener.OMIT_FOR_NEARER:
|
||||
listener.omitForNearer( node.getArtifact(), replacement );
|
||||
String version = node.getArtifact().getVersion();
|
||||
String replacementVersion = replacement.getVersion();
|
||||
if ( version != null ? !version.equals( replacementVersion ) : replacementVersion != null )
|
||||
{
|
||||
listener.omitForNearer( node.getArtifact(), replacement );
|
||||
}
|
||||
break;
|
||||
case ResolutionListener.OMIT_FOR_CYCLE:
|
||||
listener.omitForCycle( node.getArtifact() );
|
||||
|
@ -354,6 +372,13 @@ public class DefaultArtifactCollector
|
|||
case ResolutionListener.SELECT_VERSION_FROM_RANGE:
|
||||
listener.selectVersionFromRange( node.getArtifact() );
|
||||
break;
|
||||
case ResolutionListener.RESTRICT_RANGE:
|
||||
if ( node.getArtifact().getVersionRange().hasRestrictions() ||
|
||||
replacement.getVersionRange().hasRestrictions() )
|
||||
{
|
||||
listener.restrictRange( node.getArtifact(), replacement, newRange );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException( "Unknown event: " + event );
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.apache.maven.artifact.resolver;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
|
@ -48,6 +49,8 @@ public interface ResolutionListener
|
|||
|
||||
int SELECT_VERSION_FROM_RANGE = 10;
|
||||
|
||||
int RESTRICT_RANGE = 11;
|
||||
|
||||
void testArtifact( Artifact node );
|
||||
|
||||
void startProcessChildren( Artifact artifact );
|
||||
|
@ -67,4 +70,6 @@ public interface ResolutionListener
|
|||
void updateScopeCurrentPom( Artifact artifact, String scope );
|
||||
|
||||
void selectVersionFromRange( Artifact artifact );
|
||||
|
||||
void restrictRange( Artifact artifact, Artifact replacement, VersionRange newRange );
|
||||
}
|
||||
|
|
|
@ -221,11 +221,17 @@ public class VersionRange
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else if ( recommendedVersion != null )
|
||||
{
|
||||
// no range, so the recommended version is valid
|
||||
version = recommendedVersion;
|
||||
}
|
||||
/* TODO: should throw this immediately, but need artifact
|
||||
else
|
||||
{
|
||||
throw new OverConstrainedVersionException( "Restricting incompatible version ranges" );
|
||||
}
|
||||
*/
|
||||
|
||||
return new VersionRange( version, restrictions );
|
||||
}
|
||||
|
@ -501,4 +507,9 @@ public class VersionRange
|
|||
}
|
||||
return matched;
|
||||
}
|
||||
|
||||
public boolean hasRestrictions()
|
||||
{
|
||||
return !restrictions.isEmpty() && recommendedVersion == null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ public class EarMojo
|
|||
if ( !sourceFile.isFile() )
|
||||
{
|
||||
throw new MojoExecutionException( "Cannot copy a directory: " + sourceFile.getAbsolutePath() +
|
||||
"; Did you package/install " + module.getArtifact().getId() + "?" );
|
||||
"; Did you package/install " + module.getArtifact() + "?" );
|
||||
}
|
||||
|
||||
FileUtils.copyFile( module.getArtifact().getFile(), destinationFile );
|
||||
|
|
|
@ -636,7 +636,7 @@ public class PrepareReleaseMojo
|
|||
|
||||
message.append( " " );
|
||||
|
||||
message.append( artifact.getId() );
|
||||
message.append( artifact );
|
||||
|
||||
message.append( "\n" );
|
||||
}
|
||||
|
@ -901,8 +901,8 @@ public class PrepareReleaseMojo
|
|||
|
||||
if ( ArtifactUtils.isSnapshot( version ) )
|
||||
{
|
||||
throw new MojoExecutionException( "Unresolved SNAPSHOT version of: " +
|
||||
artifact.getId() + ". Cannot proceed with release." );
|
||||
throw new MojoExecutionException(
|
||||
"Unresolved SNAPSHOT version of: " + artifact + ". Cannot proceed with release." );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1155,7 +1155,7 @@ public class PrepareReleaseMojo
|
|||
}
|
||||
catch ( ArtifactMetadataRetrievalException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Cannot resolve " + artifactUsage + ": " + artifact.getId(), e );
|
||||
throw new MojoExecutionException( "Cannot resolve " + artifactUsage + ": " + artifact, e );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -322,8 +322,7 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
Model model = findModelFromRepository( artifact, remoteArtifactRepositories, localRepository, allowStubModel );
|
||||
|
||||
return build( "Artifact [" + artifact.getId() + "]", model, localRepository, remoteArtifactRepositories, null,
|
||||
null );
|
||||
return build( "Artifact [" + artifact + "]", model, localRepository, remoteArtifactRepositories, null, null );
|
||||
}
|
||||
|
||||
private Model findModelFromRepository( Artifact artifact, List remoteArtifactRepositories,
|
||||
|
@ -451,7 +450,7 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
private Model createStubModel( Artifact projectArtifact )
|
||||
{
|
||||
getLogger().warn( "\n ***** Using defaults for missing POM " + projectArtifact.getId() + " *****\n" );
|
||||
getLogger().warn( "\n ***** Using defaults for missing POM " + projectArtifact + " *****\n" );
|
||||
|
||||
Model model = new Model();
|
||||
model.setModelVersion( "4.0.0" );
|
||||
|
|
|
@ -109,7 +109,7 @@ public class MavenMetadataSource
|
|||
}
|
||||
catch ( InvalidModelException e )
|
||||
{
|
||||
getLogger().warn( "POM for: \'" + pomArtifact.getId() +
|
||||
getLogger().warn( "POM for: \'" + pomArtifact +
|
||||
"\' does not appear to be valid. Its will be ignored for artifact resolution." );
|
||||
|
||||
project = null;
|
||||
|
|
Loading…
Reference in New Issue