mirror of https://github.com/apache/maven.git
PR: MNG-1205
o Fixed unit test for resolving direct optional dependencies. o Added isChildOfRootNode() method in ResolutionNode, to check whether the parent node's parent is null. o Added check in the artifact collector to include optional artifacts if they are direct dependencies of the root node. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@332213 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ed7cc01b88
commit
1bdeecccad
|
@ -82,7 +82,7 @@ public class DefaultArtifactCollector
|
|||
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 ( !artifact.isOptional() )
|
||||
if ( node.isChildOfRootNode() || !artifact.isOptional() )
|
||||
{
|
||||
artifact.setDependencyTrail( node.getDependencyTrail() );
|
||||
|
||||
|
@ -224,7 +224,7 @@ public class DefaultArtifactCollector
|
|||
{
|
||||
ResolutionNode child = (ResolutionNode) i.next();
|
||||
// We leave in optional ones, but don't pick up its dependencies
|
||||
if ( !child.isResolved() && !child.getArtifact().isOptional() )
|
||||
if ( !child.isResolved() && ( !child.getArtifact().isOptional() || child.isChildOfRootNode() ) )
|
||||
{
|
||||
Artifact artifact = child.getArtifact();
|
||||
try
|
||||
|
|
|
@ -147,6 +147,11 @@ public class ResolutionNode
|
|||
return children != null;
|
||||
}
|
||||
|
||||
public boolean isChildOfRootNode()
|
||||
{
|
||||
return parent != null && parent.parent == null;
|
||||
}
|
||||
|
||||
public Iterator getChildrenIterator()
|
||||
{
|
||||
return children.iterator();
|
||||
|
|
|
@ -497,9 +497,8 @@ public class DefaultArtifactCollectorTest
|
|||
throws ArtifactResolutionException, InvalidVersionSpecificationException
|
||||
{
|
||||
ArtifactSpec a = createArtifact( "a", "1.0" );
|
||||
createArtifact( "b", "1.0", true );
|
||||
|
||||
ArtifactSpec b = createArtifact( "b", "1.0" );
|
||||
ArtifactSpec b = createArtifact( "b", "1.0", true );
|
||||
|
||||
ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) );
|
||||
assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() );
|
||||
|
|
Loading…
Reference in New Issue