in tools/ci/paimon-ci-tools/src/main/java/org/apache/paimon/tools/ci/utils/dependency/DependencyParser.java [134:178]
private static DependencyTree parseTreeDependencyBlock(Iterator<String> block) {
// discard one line, which only contains the current module name
block.next();
if (!block.hasNext()) {
throw new IllegalStateException("Expected more output from the dependency-plugin.");
}
final DependencyTree dependencies = new DependencyTree();
final Stack<Dependency> parentStack = new Stack<>();
final Stack<Integer> treeDepthStack = new Stack<>();
String line = block.next();
Optional<Dependency> parsedDependency = parseTreeDependency(line);
while (parsedDependency.isPresent()) {
int treeDepth = getDepth(line);
while (!treeDepthStack.isEmpty() && treeDepth <= treeDepthStack.peek()) {
parentStack.pop();
treeDepthStack.pop();
}
final Dependency dependency = parsedDependency.get();
if (parentStack.isEmpty()) {
dependencies.addDirectDependency(dependency);
} else {
dependencies.addTransitiveDependencyTo(dependency, parentStack.peek());
}
if (treeDepthStack.isEmpty() || treeDepth > treeDepthStack.peek()) {
treeDepthStack.push(treeDepth);
parentStack.push(dependency);
}
if (block.hasNext()) {
line = block.next();
parsedDependency = parseTreeDependency(line);
} else {
parsedDependency = Optional.empty();
}
}
return dependencies;
}