DependencyFilter resolutionFilter = new ScopeDependencyFilter( null, negate( scopesToResolve ) );
resolutionFilter = AndDependencyFilter.newInstance( collectionFilter, resolutionFilter );
resolutionFilter =
AndDependencyFilter.newInstance( resolutionFilter, new ReactorDependencyFilter( projectArtifacts ) );
DependencyResolutionResult result;
try
{
DefaultDependencyResolutionRequest request =
new DefaultDependencyResolutionRequest( project, session.getRepositorySession() );
request.setResolutionFilter( resolutionFilter );
eventSpyDispatcher.onEvent( request );
result = dependenciesResolver.resolve( request );
}
catch ( DependencyResolutionException e )
{
result = e.getResult();
/*
* MNG-2277, the check below compensates for our bad plugin support where we ended up with aggregator
* plugins that require dependency resolution although they usually run in phases of the build where project
* artifacts haven't been assembled yet. The prime example of this is "mvn release:prepare".
*/
if ( aggregating && areAllDependenciesInReactor( session.getProjects(), result.getUnresolvedDependencies() ) )
{
logger.warn( "The following dependencies could not be resolved at this point of the build"
+ " but seem to be part of the reactor:" );
for ( Dependency dependency : result.getUnresolvedDependencies() )
{
logger.warn( "o " + dependency );
}
logger.warn( "Try running the build up to the lifecycle phase \"package\"" );
}
else
{
throw new LifecycleExecutionException( null, project, e );
}
}
eventSpyDispatcher.onEvent( result );
Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
if ( result.getDependencyGraph() != null && !result.getDependencyGraph().getChildren().isEmpty() )
{
RepositoryUtils.toArtifacts( artifacts, result.getDependencyGraph().getChildren(),
Collections.singletonList( project.getArtifact().getId() ), collectionFilter );
}
return artifacts;
}