if ( CollectionUtils.isNotEmpty( model.getDependencyManagement() ) )
{
it = model.getDependencyManagement().iterator();
while ( it.hasNext() )
{
Dependency dependency = (Dependency) it.next();
fromNode.addDependencyManagement( dependency );
}
}
if ( CollectionUtils.isNotEmpty( model.getDependencies() ) )
{
it = model.getDependencies().iterator();
while ( it.hasNext() )
{
Dependency dependency = (Dependency) it.next();
String scope = dependency.getScope();
// Test scopes *NOT* from root node can be skipped.
if ( DependencyScope.TEST.equals( scope ) && !isRootNode )
{
// skip add of test scope
continue;
}
ArtifactReference artifactRef = new ArtifactReference();
artifactRef.setGroupId( dependency.getGroupId() );
artifactRef.setArtifactId( dependency.getArtifactId() );
artifactRef.setVersion( dependency.getVersion() );
artifactRef.setClassifier( dependency.getClassifier() );
artifactRef.setType( dependency.getType() );
DependencyGraphNode toNode = new DependencyGraphNode( artifactRef );
if ( CollectionUtils.isNotEmpty( dependency.getExclusions() ) )
{
Iterator itexclusion = dependency.getExclusions().iterator();
while ( itexclusion.hasNext() )
{
Exclusion exclusion = (Exclusion) itexclusion.next();
toNode.addExclude( exclusion );
}
}
if ( dependency.isFromParent() )
{
toNode.setFromParent( true );
}
// Add node (to)
graph.addNode( toNode );
DependencyGraphEdge edge = new DependencyGraphEdge( fromNode.getArtifact(), toNode.getArtifact() );
edge.setScope( StringUtils.defaultIfEmpty( dependency.getScope(), DependencyScope.COMPILE ) );
if ( dependency.isOptional() )
{
edge.setDisabled( true );
edge.setDisabledType( DependencyGraph.DISABLED_OPTIONAL );
edge.setDisabledReason( "Optional Dependency" );
}