/** * @param project MavenProject for which to return the dependencies. * @param session MavenSession in which to look for reactor dependencies. * @return all the dependencies for a project. * @throws DependencyGraphBuilderException if the dependency graph can't be built. */ public Set<Artifact> getProjectDependenciesFor( MavenProject project, MavenSession session ) throws DependencyGraphBuilderException { // No need to filter our search. We want to resolve all artifacts. final DependencyNode node = dependencyGraphBuilder.buildDependencyGraph( project, null, session.getProjects() ); final DependencyCollector collector = new DependencyCollector( log, project.getArtifact() ); collector.visit( node, false ); return collector.getDependencies(); }
final DependencyNode dn = dependencyGraphBuilder.buildDependencyGraph(buildingRequest, null, reactorProjects); final CollectingDependencyNodeVisitor visitor = new CollectingDependencyNodeVisitor(); dn.accept(visitor);
filter.add( optionalFilter ); final DependencyNode node = dependencyGraphBuilder.buildDependencyGraph( project, filter ); final CollectingDependencyNodeVisitor collectingVisitor = new CollectingDependencyNodeVisitor(); node.accept( collectingVisitor );
private DependencyNode getDependencyGraph(MavenProject project) { try { return dependencyGraphBuilder.buildDependencyGraph(project, new ArtifactFilter() { @Override public boolean include(Artifact artifact) { return isSensibleScope(artifact); } }); } catch (DependencyGraphBuilderException e) { throw new RuntimeException(e); } }
/** * Traverses the whole dependency tree rooted at the project. */ protected void traverseProject() throws DependencyGraphBuilderException { visit(graphBuilder.buildDependencyGraph(project, null)); }
protected DependencyNode buildDependencyGraph( MavenProject mavenProject ) throws MojoExecutionException { DependencyNode dependencyGraph; try { dependencyGraph = m_dependencyGraphBuilder.buildDependencyGraph( mavenProject, null ); } catch ( DependencyGraphBuilderException e ) { throw new MojoExecutionException( e.getMessage(), e ); } return dependencyGraph; }
protected DependencyNode createDependencyTree( MavenProject project, DependencyGraphBuilder dependencyGraphBuilder, String scope ) throws MojoExecutionException { ArtifactFilter artifactFilter = createResolvingArtifactFilter( scope ); try { return dependencyGraphBuilder.buildDependencyGraph( project, artifactFilter ); } catch ( DependencyGraphBuilderException exception ) { throw new MojoExecutionException( "Cannot build project dependency tree", exception ); } }
protected DependencyNode createDependencyTree( MavenProject project, DependencyGraphBuilder dependencyGraphBuilder, String scope ) throws MojoExecutionException { ArtifactFilter artifactFilter = createResolvingArtifactFilter( scope ); try { return dependencyGraphBuilder.buildDependencyGraph( project, artifactFilter ); } catch ( DependencyGraphBuilderException exception ) { throw new MojoExecutionException( "Cannot build project dependency tree", exception ); } }
protected Set<Artifact> getDependenciesToCheck( MavenProject project ) { Set<Artifact> dependencies = null; try { DependencyNode node = graphBuilder.buildDependencyGraph( project, null ); dependencies = getAllDescendants( node ); } catch ( DependencyGraphBuilderException e ) { // otherwise we need to change the signature of this protected method throw new RuntimeException( e ); } return dependencies; }
/** * Get root node of the current Maven project Dependency tree generated by * maven.shared dependency graph builder. * * @return root node of the project Dependency tree * @throws MojoExecutionException */ protected DependencyNode getRootNodeDependecyTree() throws MojoExecutionException{ try { ArtifactFilter artifactFilter = null; // works for only maven 3. Use of dependency graph component not handled for maven 2 // as current version of NAR already requires Maven 3.x rootNode = dependencyGraphBuilder.buildDependencyGraph(getMavenProject(), artifactFilter); } catch (DependencyGraphBuilderException exception) { throw new MojoExecutionException("Cannot build project dependency graph", exception); } return rootNode; }
/** * Build dependency graph. * @return Root of dependency graph. * @throws DependencyGraphBuilderException In case of error. */ private DependencyNode graph() throws DependencyGraphBuilderException { return this.builder.buildDependencyGraph( this.session.getCurrentProject(), new ArtifactFilter() { @Override public boolean include( final Artifact artifact) { return MavenClasspath.this.scopes .contains(artifact.getScope()); } } ); }
/** * @return resolve the dependency tree */ private DependencyNode resolveProject() { try { ArtifactFilter artifactFilter = new ScopeArtifactFilter( Artifact.SCOPE_TEST ); return dependencyGraphBuilder.buildDependencyGraph( project, artifactFilter ); } catch ( DependencyGraphBuilderException e ) { getLog().error( "Unable to build dependency tree.", e ); return null; } }
protected Set<Artifact> getDependenciesToCheck( MavenProject project ) { Set<Artifact> dependencies = null; try { DependencyNode node = graphBuilder.buildDependencyGraph( project, null ); if ( searchTransitive ) { dependencies = getAllDescendants( node ); } else if ( node.getChildren() != null ) { dependencies = new HashSet<Artifact>(); for ( DependencyNode depNode : node.getChildren() ) { dependencies.add( depNode.getArtifact() ); } } } catch ( DependencyGraphBuilderException e ) { // otherwise we need to change the signature of this protected method throw new RuntimeException( e ); } return dependencies; }
protected Set<Artifact> getDependenciesToCheck( MavenProject project ) { Set<Artifact> dependencies = null; try { DependencyNode node = graphBuilder.buildDependencyGraph( project, null ); if ( searchTransitive ) { dependencies = getAllDescendants( node ); } else if ( node.getChildren() != null ) { dependencies = new HashSet<Artifact>(); for ( DependencyNode depNode : node.getChildren() ) { dependencies.add( depNode.getArtifact() ); } } } catch ( DependencyGraphBuilderException e ) { // otherwise we need to change the signature of this protected method throw new RuntimeException( e ); } return dependencies; }
try { Set<Artifact> transitives = new LinkedHashSet<>(); DependencyNode node = graph.buildDependencyGraph(mojo.project, filter); node.accept(new ArtifactVisitor(mojo, transitives)); mojo.getLog().debug(transitives.size() + " transitive dependencies have been collected : " +
/** * Builds a dependency graph. * * @param project the project * @param filter artifact filter (can be <code>null</code>) * @param reactorProjects Collection of those projects contained in the reactor (can be <code>null</code>) * @return DependencyNode containing the dependency graph. * @throws DependencyGraphBuilderException if some of the dependencies could not be resolved. */ public DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter, Collection<MavenProject> reactorProjects ) throws DependencyGraphBuilderException { try { String hint = isMaven31() ? "maven31" : isMaven2x() ? "maven2" : "maven3"; DependencyGraphBuilder effectiveGraphBuilder = (DependencyGraphBuilder) container.lookup( DependencyGraphBuilder.class.getCanonicalName(), hint ); getLogger().debug( "building " + hint + " dependency graph for " + project.getId() + " with " + effectiveGraphBuilder.getClass().getSimpleName() ); return effectiveGraphBuilder.buildDependencyGraph( project, filter, reactorProjects ); } catch ( ComponentLookupException e ) { throw new DependencyGraphBuilderException( e.getMessage(), e ); } }
return effectiveGraphBuilder.buildDependencyGraph( buildingRequest, filter, reactorProjects );
rootNode = createDependencyGraphBuilder().buildDependencyGraph( project, null );
rootNode = createDependencyGraphBuilder().buildDependencyGraph( project, null );
rootNode = dependencyGraphBuilder.buildDependencyGraph( buildingRequest, artifactFilter, reactorProjects );