/** * Gets whether the first dependency node is an ancestor-or-self of the second. * * @param ancestorNode the ancestor-or-self dependency node * @param descendantNode the dependency node to test * @return <code>true</code> if <code>ancestorNode</code> is an ancestor, or equal to, <code>descendantNode</code> */ private boolean isAncestorOrSelf( DependencyNode ancestorNode, DependencyNode descendantNode ) { boolean ancestor = false; while ( !ancestor && descendantNode != null ) { ancestor = ancestorNode.equals( descendantNode ); descendantNode = descendantNode.getParent(); } return ancestor; } }
/** * Gets whether the first dependency node is an ancestor-or-self of the second. * * @param ancestorNode the ancestor-or-self dependency node * @param descendantNode the dependency node to test * @return <code>true</code> if <code>ancestorNode</code> is an ancestor, or equal to, <code>descendantNode</code> */ private boolean isAncestorOrSelf( DependencyNode ancestorNode, DependencyNode descendantNode ) { boolean ancestor = false; while ( !ancestor && descendantNode != null ) { ancestor = ancestorNode.equals( descendantNode ); descendantNode = descendantNode.getParent(); } return ancestor; } }
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; }
/** * Gets whether the specified dependency node ancestor is the last of its siblings. * * @param node the dependency node whose ancestor to check * @param ancestorDepth the depth of the ancestor of the specified dependency node to check * @return <code>true</code> if the specified dependency node ancestor is the last of its siblings */ private boolean isLast( DependencyNode node, int ancestorDepth ) { // TODO: remove node argument and calculate from visitor calls only int distance = depth - ancestorDepth; while ( distance-- > 0 ) { node = node.getParent(); } return isLast( node ); } }
/** * {@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; }
/** * Gets whether the specified dependency node ancestor is the last of its siblings. * * @param node the dependency node whose ancestor to check * @param ancestorDepth the depth of the ancestor of the specified dependency node to check * @return <code>true</code> if the specified dependency node ancestor is the last of its siblings */ private boolean isLast( DependencyNode node, int ancestorDepth ) { // TODO: remove node argument and calculate from visitor calls only int distance = depth - ancestorDepth; while ( distance-- > 0 ) { node = node.getParent(); } return isLast( node ); } }
/** * 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; }
/** * 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 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 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 endVisit( DependencyNode node ) { if ( node.getParent() == null || node.getParent() == node ) { writer.write( GRAPHML_FOOTER ); } else { DependencyNode p = node.getParent(); writer.print( "<edge source=\"" + generateId( p ) + "\" target=\"" + generateId( node ) + "\">" ); if ( node.getArtifact().getScope() != null ) { // add Edge label writer.print( "<data key=\"d1\"><y:PolyLineEdge><y:EdgeLabel>" + node.getArtifact().getScope() + "</y:EdgeLabel></y:PolyLineEdge></data>" ); } writer.println( "</edge>" ); } return true; }
@Override protected boolean accept(DependencyNode g) { MavenArtifact a = wrap(g.getArtifact()); if (!parsedScopes.contains(a.getScope())) return false; if (!includesOptional && a.isOptional()) return false; // cut off optional dependencies try { if (!a.isPlugin()) return g.getParent()==null; // only traverse chains of direct plugin dependencies, unless it's from the root } catch (IOException e) { getLog().warn("Failed to process "+a, e); } MavenArtifact v = hpis.get(a.getArtifactId()); if (v==null || a.isNewerThan(v)) hpis.put(a.getArtifactId(),a); return true; }