mirror of https://github.com/apache/maven.git
PR: MNG-1233
corrected handling of scope based exclusions git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@326363 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
15442309bd
commit
31f17512f5
|
@ -79,8 +79,10 @@ public class DefaultArtifactCollector
|
||||||
{
|
{
|
||||||
Artifact artifact = node.getArtifact();
|
Artifact artifact = node.getArtifact();
|
||||||
|
|
||||||
|
if ( node.filterTrail( filter ) )
|
||||||
|
{
|
||||||
// If it was optional, we don't add it or its children, just allow the update of the version and scope
|
// If it was optional, we don't add it or its children, just allow the update of the version and scope
|
||||||
if ( !node.getArtifact().isOptional() )
|
if ( !artifact.isOptional() )
|
||||||
{
|
{
|
||||||
artifact.setDependencyTrail( node.getDependencyTrail() );
|
artifact.setDependencyTrail( node.getDependencyTrail() );
|
||||||
|
|
||||||
|
@ -89,6 +91,7 @@ public class DefaultArtifactCollector
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ArtifactResolutionResult result = new ArtifactResolutionResult();
|
ArtifactResolutionResult result = new ArtifactResolutionResult();
|
||||||
result.setArtifactResolutionNodes( set );
|
result.setArtifactResolutionNodes( set );
|
||||||
|
@ -165,10 +168,12 @@ public class DefaultArtifactCollector
|
||||||
for ( int j = 0; j < 2; j++ )
|
for ( int j = 0; j < 2; j++ )
|
||||||
{
|
{
|
||||||
Artifact resetArtifact = resetNodes[j].getArtifact();
|
Artifact resetArtifact = resetNodes[j].getArtifact();
|
||||||
if ( resetArtifact.getVersion() == null && resetArtifact.getVersionRange() != null && resetArtifact.getAvailableVersions() != null )
|
if ( resetArtifact.getVersion() == null && resetArtifact.getVersionRange() != null &&
|
||||||
|
resetArtifact.getAvailableVersions() != null )
|
||||||
{
|
{
|
||||||
|
|
||||||
resetArtifact.selectVersion( resetArtifact.getVersionRange().matchVersion( resetArtifact.getAvailableVersions() ).toString() );
|
resetArtifact.selectVersion( resetArtifact.getVersionRange().matchVersion(
|
||||||
|
resetArtifact.getAvailableVersions() ).toString() );
|
||||||
fireEvent( ResolutionListener.SELECT_VERSION_FROM_RANGE, listeners, resetNodes[j] );
|
fireEvent( ResolutionListener.SELECT_VERSION_FROM_RANGE, listeners, resetNodes[j] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.artifact.resolver;
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||||
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
|
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
|
||||||
import org.apache.maven.artifact.versioning.VersionRange;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -44,6 +43,8 @@ public class ResolutionNode
|
||||||
|
|
||||||
private boolean active = true;
|
private boolean active = true;
|
||||||
|
|
||||||
|
private List trail;
|
||||||
|
|
||||||
public ResolutionNode( Artifact artifact, List remoteRepositories )
|
public ResolutionNode( Artifact artifact, List remoteRepositories )
|
||||||
{
|
{
|
||||||
this.artifact = artifact;
|
this.artifact = artifact;
|
||||||
|
@ -85,8 +86,6 @@ public class ResolutionNode
|
||||||
{
|
{
|
||||||
Artifact a = (Artifact) i.next();
|
Artifact a = (Artifact) i.next();
|
||||||
|
|
||||||
if ( filter == null || filter.include( a ) )
|
|
||||||
{
|
|
||||||
if ( parents.contains( a.getDependencyConflictId() ) )
|
if ( parents.contains( a.getDependencyConflictId() ) )
|
||||||
{
|
{
|
||||||
a.setDependencyTrail( getDependencyTrail() );
|
a.setDependencyTrail( getDependencyTrail() );
|
||||||
|
@ -97,17 +96,33 @@ public class ResolutionNode
|
||||||
children.add( new ResolutionNode( a, remoteRepositories, this ) );
|
children.add( new ResolutionNode( a, remoteRepositories, this ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
children = Collections.EMPTY_LIST;
|
children = Collections.EMPTY_LIST;
|
||||||
}
|
}
|
||||||
|
trail = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getDependencyTrail()
|
public List getDependencyTrail()
|
||||||
throws OverConstrainedVersionException
|
throws OverConstrainedVersionException
|
||||||
{
|
{
|
||||||
List path = new LinkedList();
|
List trial = getTrail();
|
||||||
|
|
||||||
|
List ret = new ArrayList( trial.size() );
|
||||||
|
for ( Iterator i = trial.iterator(); i.hasNext(); )
|
||||||
|
{
|
||||||
|
Artifact artifact = (Artifact) i.next();
|
||||||
|
ret.add( artifact.getId() );
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List getTrail()
|
||||||
|
throws OverConstrainedVersionException
|
||||||
|
{
|
||||||
|
if ( trail == null )
|
||||||
|
{
|
||||||
|
List ids = new LinkedList();
|
||||||
ResolutionNode node = this;
|
ResolutionNode node = this;
|
||||||
while ( node != null )
|
while ( node != null )
|
||||||
{
|
{
|
||||||
|
@ -115,15 +130,16 @@ public class ResolutionNode
|
||||||
if ( artifact.getVersion() == null )
|
if ( artifact.getVersion() == null )
|
||||||
{
|
{
|
||||||
// set the recommended version
|
// set the recommended version
|
||||||
VersionRange versionRange = artifact.getVersionRange();
|
|
||||||
String version = artifact.getSelectedVersion().toString();
|
String version = artifact.getSelectedVersion().toString();
|
||||||
artifact.selectVersion( version );
|
artifact.selectVersion( version );
|
||||||
}
|
}
|
||||||
|
|
||||||
path.add( 0, artifact.getId() );
|
ids.add( 0, artifact );
|
||||||
node = node.parent;
|
node = node.parent;
|
||||||
}
|
}
|
||||||
return path;
|
trail = ids;
|
||||||
|
}
|
||||||
|
return trail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isResolved()
|
public boolean isResolved()
|
||||||
|
@ -177,4 +193,22 @@ public class ResolutionNode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean filterTrail( ArtifactFilter filter )
|
||||||
|
throws OverConstrainedVersionException
|
||||||
|
{
|
||||||
|
boolean success = true;
|
||||||
|
if ( filter != null )
|
||||||
|
{
|
||||||
|
for ( Iterator i = getTrail().iterator(); i.hasNext() && success; )
|
||||||
|
{
|
||||||
|
Artifact artifact = (Artifact) i.next();
|
||||||
|
if ( !filter.include( artifact ) )
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,8 +98,7 @@ public class ScopeArtifactFilter
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: should this be true? Does it even happen?
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue