use of org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor in project maven-plugins by apache.
the class TreeMojo method serializeDependencyTree.
/**
* Serializes the specified dependency tree to a string.
*
* @param rootNode the dependency tree root node to serialize
* @return the serialized dependency tree
*/
private String serializeDependencyTree(DependencyNode rootNode) {
StringWriter writer = new StringWriter();
DependencyNodeVisitor visitor = getSerializingDependencyNodeVisitor(writer);
// TODO: remove the need for this when the serializer can calculate last nodes from visitor calls only
visitor = new BuildingDependencyNodeVisitor(visitor);
DependencyNodeFilter filter = createDependencyNodeFilter();
if (filter != null) {
CollectingDependencyNodeVisitor collectingVisitor = new CollectingDependencyNodeVisitor();
DependencyNodeVisitor firstPassVisitor = new FilteringDependencyNodeVisitor(collectingVisitor, filter);
rootNode.accept(firstPassVisitor);
DependencyNodeFilter secondPassFilter = new AncestorOrSelfDependencyNodeFilter(collectingVisitor.getNodes());
visitor = new FilteringDependencyNodeVisitor(visitor, secondPassFilter);
}
rootNode.accept(visitor);
return writer.toString();
}
Aggregations