Search in sources :

Example 1 with DependencyGraphBuilderException

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);
    }
}
Also used : StrictPatternExcludesArtifactFilter(org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter) ArtifactFilter(org.apache.maven.artifact.resolver.filter.ArtifactFilter) StrictPatternIncludesArtifactFilter(org.apache.maven.shared.artifact.filter.StrictPatternIncludesArtifactFilter) ScopeArtifactFilter(org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter) ProjectBuildingRequest(org.apache.maven.project.ProjectBuildingRequest) DefaultProjectBuildingRequest(org.apache.maven.project.DefaultProjectBuildingRequest) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) DependencyGraphBuilderException(org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException) IOException(java.io.IOException) DefaultProjectBuildingRequest(org.apache.maven.project.DefaultProjectBuildingRequest)

Aggregations

IOException (java.io.IOException)1 ArtifactFilter (org.apache.maven.artifact.resolver.filter.ArtifactFilter)1 ScopeArtifactFilter (org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 DefaultProjectBuildingRequest (org.apache.maven.project.DefaultProjectBuildingRequest)1 ProjectBuildingRequest (org.apache.maven.project.ProjectBuildingRequest)1 StrictPatternExcludesArtifactFilter (org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter)1 StrictPatternIncludesArtifactFilter (org.apache.maven.shared.artifact.filter.StrictPatternIncludesArtifactFilter)1 DependencyGraphBuilderException (org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException)1