Class CycleAwareDependencyGraphDumper

  • All Implemented Interfaces:
    org.eclipse.aether.graph.DependencyVisitor

    public class CycleAwareDependencyGraphDumper
    extends DependencyGraphDumper
    A DependencyGraphDumper that is safe to use on a graph containing cycles: a dependency graph in FULL verbosity mode may contain nodes that (directly or transitively) depend on an ancestor of themselves, which makes the plain DependencyGraphDumper recurse forever. Wrapping it in TreeDependencyVisitor avoids the stack overflow but also hides every node that was already visited anywhere else in the graph, so a node reached a second time through a different path (a perfectly normal diamond dependency, not a cycle) is silently dropped from the output as well.

    This dumper only checks the path from the root to the node currently being visited: a node is only treated as a cycle when it is already one of its own ancestors. Diamonds are still printed in full, and a true cycle is printed once, marked, with its subtree cut off instead of being recursed into.

    Since:
    2.0.25
    • Constructor Detail

      • CycleAwareDependencyGraphDumper

        public CycleAwareDependencyGraphDumper​(java.util.function.Consumer<java.lang.String> consumer)
        Creates instance with given consumer.
        Parameters:
        consumer - the string consumer, must not be null
      • CycleAwareDependencyGraphDumper

        public CycleAwareDependencyGraphDumper​(java.util.function.Consumer<java.lang.String> consumer,
                                               java.util.Collection<java.util.function.Function<org.eclipse.aether.graph.DependencyNode,​java.lang.String>> decorators)
        Creates instance with given consumer and decorators.
        Parameters:
        consumer - the string consumer, must not be null
        decorators - the decorators to apply, must not be null
    • Method Detail

      • visitEnter

        public boolean visitEnter​(org.eclipse.aether.graph.DependencyNode node)
        Specified by:
        visitEnter in interface org.eclipse.aether.graph.DependencyVisitor
        Overrides:
        visitEnter in class DependencyGraphDumper