private void buildGraph(ArtifactResolver artifactResolver, DependencyOptions options) throws MojoExecutionException { GraphBuilder graphBuilder = new BreadthFirstGraphBuilder(getLog(), artifactResolver); Graph graph = graphBuilder.buildGraph( new ArtifactRevisionIdentifier(artifactId, groupId, version), options); GraphSerializer graphSerializer = new GraphMLGenerator(); try { File file = new File( outputDirectory, this.artifactId + "-" + this.version + "-" + options.getGraphType() + (options.isIncludeAllTransitiveDependencies() ? "-TRANSITIVE" : "") + "-deps.graphml"); graphSerializer.serialize( graph, new FileWriter(file), new RenderOptions().setVertexRenderer(new SizeVertexRenderer())); getLog().info("Created dependency graph in " + file); } catch (IOException e) { throw new MojoExecutionException("Can't write to file", e); } }
public void execute() throws MojoExecutionException { getLog().info("Using graph.reports=" + reports); List<DependencyOptions> reportDefinitions = DependencyOptions.parseReportDefinitions(reports); ArtifactResolver artifactResolver = new MavenArtifactResolver( getLog(), localRepository, this.artifactFactory, mavenProjectBuilder); for (DependencyOptions reportDefinition : reportDefinitions) { buildGraph(artifactResolver, reportDefinition); } }