use of org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException in project maven-plugins by apache.
the class TreeMojo method execute.
// Mojo methods -----------------------------------------------------------
/*
* @see org.apache.maven.plugin.Mojo#execute()
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (isSkip()) {
getLog().info("Skipping plugin execution");
return;
}
try {
String dependencyTreeString;
// TODO: note that filter does not get applied due to MSHARED-4
ArtifactFilter artifactFilter = createResolvingArtifactFilter();
if (verbose) {
// To fix we probably need a different DependencyCollector in Aether, which doesn't remove nodes which
// have already been resolved.
getLog().info("Verbose not supported since maven-dependency-plugin 3.0");
}
ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest());
buildingRequest.setProject(project);
// non-verbose mode use dependency graph component, which gives consistent results with Maven version
// running
rootNode = dependencyGraphBuilder.buildDependencyGraph(buildingRequest, artifactFilter, reactorProjects);
dependencyTreeString = serializeDependencyTree(rootNode);
if (outputFile != null) {
DependencyUtil.write(dependencyTreeString, outputFile, this.appendOutput, getLog());
getLog().info("Wrote dependency tree to: " + outputFile);
} else {
DependencyUtil.log(dependencyTreeString, getLog());
}
} catch (DependencyGraphBuilderException exception) {
throw new MojoExecutionException("Cannot build project dependency graph", exception);
} catch (IOException exception) {
throw new MojoExecutionException("Cannot serialise project dependency graph", exception);
}
}
Aggregations