![JAR search and dependency download from the Maven repository](/logo.png)
org.carlspring.maven.commons.util.DependencyNodeUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maven-commons Show documentation
Show all versions of maven-commons Show documentation
A library for common Maven operations.
The newest version!
package org.carlspring.maven.commons.util;
import org.apache.maven.shared.dependency.tree.DependencyNode;
/**
* @author mtodorov
*/
public class DependencyNodeUtils
{
public static int getDepth(DependencyNode node)
{
int depth = 0;
DependencyNode parent = node;
while ((parent = parent.getParent()) != null)
{
depth += 2;
}
return depth;
}
public static String pad(int n, char c)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++)
{
sb.append(c);
}
return sb.toString();
}
public static String getState(DependencyNode node)
{
switch (node.getState())
{
case DependencyNode.INCLUDED:
return "included";
case DependencyNode.OMITTED_FOR_DUPLICATE:
return "omitted for duplicate";
case DependencyNode.OMITTED_FOR_CONFLICT:
return "omitted for conflict with " + node.getRelatedArtifact().getVersion();
case DependencyNode.OMITTED_FOR_CYCLE:
return "omitted for cycle";
}
throw new RuntimeException("Invalid dependency node state!");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy