]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.aether/src/main/java/org/argeo/slc/aether/AetherUtils.java
SLC Repo
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.aether / src / main / java / org / argeo / slc / aether / AetherUtils.java
1 package org.argeo.slc.aether;
2
3 import org.apache.commons.logging.Log;
4 import org.apache.commons.logging.LogFactory;
5 import org.sonatype.aether.artifact.Artifact;
6 import org.sonatype.aether.graph.DependencyNode;
7
8 /** Utilities related to Aether */
9 public class AetherUtils {
10 private final static Log log = LogFactory.getLog(AetherUtils.class);
11
12 /** Logs a dependency node and its transitive dependencies as a tree. */
13 public static void logDependencyNode(int depth,
14 DependencyNode dependencyNode) {
15 if (!log.isDebugEnabled())
16 return;
17
18 StringBuffer prefix = new StringBuffer(depth * 2 + 2);
19 // prefix.append("|-");
20 for (int i = 0; i < depth * 2; i++) {
21 prefix.append(' ');
22 }
23 Artifact artifact = dependencyNode.getDependency().getArtifact();
24 log.debug(prefix + "|-> " + artifact.getArtifactId() + " ["
25 + artifact.getVersion() + "]"
26 + (dependencyNode.getDependency().isOptional() ? " ?" : ""));
27 for (DependencyNode child : dependencyNode.getChildren()) {
28 logDependencyNode(depth + 1, child);
29 }
30 }
31
32 }