/** * Visits all nodes from the given node and collects dependencies. * * @param node DependencyNode from which to search. * @param collecting Whether we are currently collecting artifacts. */ public void visit( DependencyNode node, boolean collecting ) { if ( collecting ) { dependencies.add( node.getArtifact() ); } if ( matchesTarget( node.getArtifact() ) ) { collecting = true; log.debug( "Found target. Collecting dependencies after " + node.getArtifact() ); } for ( final DependencyNode child : node.getChildren() ) { visit( child, collecting ); } }
final DependencyNode dn = dependencyGraphBuilder.buildDependencyGraph(buildingRequest, null, reactorProjects); final CollectingDependencyNodeVisitor visitor = new CollectingDependencyNodeVisitor(); dn.accept(visitor); if (filter.include(node.getArtifact())) { nodes.add(node);
ExceptionCollection exCol = collectDependencyManagementDependencies(buildingRequest, project, nodes, aggregate); for (DependencyNode dependencyNode : nodes) { if (artifactScopeExcluded.passes(dependencyNode.getArtifact().getScope()) || artifactTypeExcluded.passes(dependencyNode.getArtifact().getType())) { continue; String version = null; List<ArtifactVersion> availableVersions = null; if (org.apache.maven.artifact.Artifact.SCOPE_SYSTEM.equals(dependencyNode.getArtifact().getScope())) { for (org.apache.maven.model.Dependency d : project.getDependencies()) { final Artifact a = dependencyNode.getArtifact(); if (d.getSystemPath() != null && artifactsMatch(d, a)) { getLog().error("Unable to resolve system scoped dependency: " + dependencyNode.toNodeString()); if (exCol == null) { exCol = new ExceptionCollection(); + dependencyNode.toNodeString())); final ArtifactCoordinate coordinate = TransferUtils.toArtifactCoordinate(dependencyNode.getArtifact()); final Artifact result; try { getLog().debug(String.format("Aggregate : %s", aggregate)); boolean addException = true; if (!aggregate || addReactorDependency(engine, dependencyNode.getArtifact())) { addException = false; && dependencyNode.getArtifact().isSnapshot() && aggregate
@Override public Artifact apply(DependencyNode input) { return input.getArtifact(); } }));
/** * {@inheritDoc} */ @Override public boolean visit( DependencyNode node ) { // clone the node DefaultDependencyNode newNode = new DefaultDependencyNode( parentNodes.isEmpty() ? null : parentNodes.peek(), node.getArtifact(), node.getPremanagedVersion(), node.getPremanagedScope(), node.getVersionConstraint(), node.getOptional() ); newNode.setChildren( new ArrayList<DependencyNode>() ); if ( parentNodes.empty() ) { rootNode = newNode; } else { DependencyNode parentNode = parentNodes.peek(); parentNode.getChildren().add( newNode ); } parentNodes.push( newNode ); return true; }
private List<Artifact> getHierarchyChain(DependencyNode baseNode) { List<Artifact> chain = new ArrayList<Artifact>(); DependencyNode node = baseNode; while((node = node.getParent()) != null) { chain.add(node.getArtifact()); } return chain; }
/** * Find all of the dependencies for a specified artifact */ private List<PackageDescriptor> addPackageDependencies(PackageDescriptor parent, String groupId, String artifactId, String version, DependencyNode parentDep) { List<PackageDescriptor> packageDependency = new LinkedList<PackageDescriptor>(); List<DependencyNode> children = parentDep.getChildren(); if (children != null) { for (DependencyNode node : children) { DependencyNodeVisitor nlg = new CollectingDependencyNodeVisitor(); node.accept(nlg); List<DependencyNode> deps = ((CollectingDependencyNodeVisitor) nlg).getNodes(); for (DependencyNode dep : deps) { Artifact artifact = dep.getArtifact(); PackageDescriptor pkgDep = new PackageDescriptor("maven", artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()); // Only include each package once. They might be transitive dependencies from multiple places. if (!parents.containsKey(pkgDep)) { pkgDep = request.add("maven", artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()); parents.put(pkgDep, parent); packageDependency.add(pkgDep); } } } } return packageDependency; }
/** * {@inheritDoc} */ public boolean endVisit( DependencyNode node ) { parentNodes.pop(); // apply the visitor to the resultant tree on the last visit if ( parentNodes.empty() && visitor != null ) { rootNode.accept( visitor ); } return true; }
/** * helper function for traversing nodes * in Level-Order way (also called BFS algorithm) */ private List<DependencyNode> levelTraverseTreeList(List<DependencyNode> nodeList, List <DependencyNode> aggDepNodeList ) { aggDepNodeList.addAll(nodeList); List<DependencyNode> NodeChildList = new ArrayList<DependencyNode>(); for (DependencyNode node : nodeList) { if ( (node != null) && (node.getChildren() != null) ) { NodeChildList.addAll(node.getChildren()); } } return NodeChildList; }
/** * Gets whether the specified dependency node is the last of its siblings. * * @param node the dependency node to check * @return <code>true</code> if the specified dependency node is the last of its last siblings */ private boolean isLast( DependencyNode node ) { // TODO: remove node argument and calculate from visitor calls only DependencyNode parent = node.getParent(); boolean last; if ( parent == null ) { last = true; } else { List<DependencyNode> siblings = parent.getChildren(); last = ( siblings.indexOf( node ) == siblings.size() - 1 ); } return last; }
/** * {@inheritDoc} */ @Override public boolean visit( DependencyNode node ) { if ( node.getParent() == null || node.getParent() == node ) { writer.write( "digraph \"" + node.toNodeString() + "\" { \n" ); } // Generate "currentNode -> Child" lines List<DependencyNode> children = node.getChildren(); for ( DependencyNode child : children ) { writer.println( "\t\"" + node.toNodeString() + "\" -> \"" + child.toNodeString() + "\" ; " ); } return true; }
/** * {@inheritDoc} */ @Override public boolean visit( DependencyNode node ) { if ( node.getParent() == null || node.getParent() == node ) { writer.write( GRAPHML_HEADER ); } // write node writer.print( "<node id=\"" + generateId( node ) + "\">" ); // add node label writer.print( "<data key=\"d0\"><y:ShapeNode><y:NodeLabel>" + node.toNodeString() + "</y:NodeLabel></y:ShapeNode></data>" ); writer.println( "</node>" ); return true; }
/** * {@inheritDoc} */ @Override public boolean visit( DependencyNode node ) { indent( node ); writer.println( node.toNodeString() ); depth++; return true; }
@Override public boolean endVisit(DependencyNode node) { Artifact artifact = node.getArtifact(); Optional<Dependency> dependencyOption = artifactInConfiguredList(artifact, configuredScannedDependencies); if (dependencyOption.isPresent()) { artifacts.addAll(findIncludedTransitiveDeps(node, dependencyOption.get())); } return true; } });
/** * {@inheritDoc} */ public boolean visit( DependencyNode node ) { // clone the node DefaultDependencyNode newNode = new DefaultDependencyNode( parentNodes.isEmpty() ? null : parentNodes.peek(), node.getArtifact(), node.getPremanagedVersion(), node.getPremanagedScope(), node.getVersionConstraint() ); newNode.setChildren( new ArrayList<DependencyNode>() ); if ( parentNodes.empty() ) { rootNode = newNode; } else { DependencyNode parentNode = parentNodes.peek(); parentNode.getChildren().add( newNode ); } parentNodes.push( newNode ); return true; }
/** * {@inheritDoc} */ @Override public boolean endVisit( DependencyNode node ) { if ( node.getParent() == null || node.getParent() == node ) { // dump edges on last node endVisit writer.println( "#" ); for ( EdgeAppender edge : edges ) { writer.println( edge.toString() ); } } else { DependencyNode p = node.getParent(); // using scope as edge label. edges.add( new EdgeAppender( p, node, node.getArtifact().getScope() ) ); } return true; }
/** * {@inheritDoc} */ @Override public boolean endVisit( DependencyNode node ) { parentNodes.pop(); // apply the visitor to the resultant tree on the last visit if ( parentNodes.empty() && visitor != null ) { rootNode.accept( visitor ); } return true; }
public boolean accept( DependencyNode node ) { boolean accepted = dependencyNodeFilter.accept( node ); if( !accepted ) { List<DependencyNode> children = node.getChildren(); children.clear(); } return accepted; } }
/** * Gets whether the specified dependency node is the last of its siblings. * * @param node the dependency node to check * @return <code>true</code> if the specified dependency node is the last of its last siblings */ private boolean isLast( DependencyNode node ) { // TODO: remove node argument and calculate from visitor calls only DependencyNode parent = node.getParent(); boolean last; if ( parent == null ) { last = true; } else { List<DependencyNode> siblings = parent.getChildren(); last = ( siblings.indexOf( node ) == siblings.size() - 1 ); } return last; }