}
DependencyFilter filter = request.getResolutionFilter();
ArtifactTypeRegistry stereotypes = session.getArtifactTypeRegistry();
CollectRequest collect = new CollectRequest();
collect.setRootArtifact( RepositoryUtils.toArtifact( project.getArtifact() ) );
collect.setRequestContext( "project" );
collect.setRepositories( project.getRemoteProjectRepositories() );
if ( project.getDependencyArtifacts() == null )
{
for ( Dependency dependency : project.getDependencies() )
{
if ( StringUtils.isEmpty( dependency.getGroupId() ) || StringUtils.isEmpty( dependency.getArtifactId() )
|| StringUtils.isEmpty( dependency.getVersion() ) )
{
// guard against case where best-effort resolution for invalid models is requested
continue;
}
collect.addDependency( RepositoryUtils.toDependency( dependency, stereotypes ) );
}
}
else
{
Map<String, Dependency> dependencies = new HashMap<String, Dependency>();
for ( Dependency dependency : project.getDependencies() )
{
String classifier = dependency.getClassifier();
if ( classifier == null )
{
ArtifactType type = stereotypes.get( dependency.getType() );
if ( type != null )
{
classifier = type.getClassifier();
}
}
String key =
ArtifactIdUtils.toVersionlessId( dependency.getGroupId(), dependency.getArtifactId(),
dependency.getType(), classifier );
dependencies.put( key, dependency );
}
for ( Artifact artifact : project.getDependencyArtifacts() )
{
String key = artifact.getDependencyConflictId();
Dependency dependency = dependencies.get( key );
Collection<Exclusion> exclusions = dependency != null ? dependency.getExclusions() : null;
org.eclipse.aether.graph.Dependency dep = RepositoryUtils.toDependency( artifact, exclusions );
if ( !JavaScopes.SYSTEM.equals( dep.getScope() ) && dep.getArtifact().getFile() != null )
{
// enable re-resolution
org.eclipse.aether.artifact.Artifact art = dep.getArtifact();
art = art.setFile( null ).setVersion( art.getBaseVersion() );
dep = dep.setArtifact( art );
}
collect.addDependency( dep );
}
}
DependencyManagement depMngt = project.getDependencyManagement();
if ( depMngt != null )
{
for ( Dependency dependency : depMngt.getDependencies() )
{
collect.addManagedDependency( RepositoryUtils.toDependency( dependency, stereotypes ) );
}
}
DependencyRequest depRequest = new DependencyRequest( collect, filter );
depRequest.setTrace( trace );
DependencyNode node;
try
{
collect.setTrace( RequestTrace.newChild( trace, depRequest ) );
node = repoSystem.collectDependencies( session, collect ).getRoot();
result.setDependencyGraph( node );
}
catch ( DependencyCollectionException e )
{