use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class UnsolvableVersionConflictException method toPath.
private static String toPath(List<DependencyNode> path) {
StringBuilder buffer = new StringBuilder(256);
for (Iterator<DependencyNode> it = path.iterator(); it.hasNext(); ) {
DependencyNode node = it.next();
if (node.getDependency() == null) {
continue;
}
Artifact artifact = node.getDependency().getArtifact();
buffer.append(artifact.getGroupId());
buffer.append(':').append(artifact.getArtifactId());
buffer.append(':').append(artifact.getExtension());
if (artifact.getClassifier().length() > 0) {
buffer.append(':').append(artifact.getClassifier());
}
buffer.append(':').append(node.getVersionConstraint());
if (it.hasNext()) {
buffer.append(" -> ");
}
}
return buffer.toString();
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class DefaultDependencyCollectorTest method testDuplicates.
@Test
public void testDuplicates() throws IOException, DependencyCollectionException {
DependencyNode root = parser.parseLiteral("duplicate:transitive:ext:dependency");
Dependency dependency = root.getDependency();
CollectRequest request = new CollectRequest(dependency, Arrays.asList(repository));
CollectResult result = collector.collectDependencies(session, request);
assertEquals(0, result.getExceptions().size());
DependencyNode newRoot = result.getRoot();
Dependency newDependency = newRoot.getDependency();
assertEquals(dependency, newDependency);
assertEquals(dependency.getArtifact(), newDependency.getArtifact());
assertEquals(2, newRoot.getChildren().size());
DependencyNode expect = parser.parseLiteral("gid:aid:ext:ver:compile");
Dependency dep = expect.getDependency();
assertEquals(dep, dep(newRoot, 0));
expect = parser.parseLiteral("gid:aid2:ext:ver:compile");
dep = expect.getDependency();
assertEquals(dep, dep(newRoot, 1));
assertEquals(dep, dep(newRoot, 0, 0));
assertEquals(dep(newRoot, 1), dep(newRoot, 0, 0));
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class DefaultDependencyCollectorTest method testEqualSubtree.
@Test
public void testEqualSubtree() throws IOException, DependencyCollectionException {
DependencyNode root = parser.parse("expectedSubtreeComparisonResult.txt");
Dependency dependency = root.getDependency();
CollectRequest request = new CollectRequest(dependency, Arrays.asList(repository));
CollectResult result = collector.collectDependencies(session, request);
assertEqualSubtree(root, result.getRoot());
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class DependencyGraphParserTest method testComments.
@Test
public void testComments() throws IOException {
String def = "# first line\n#second line\ngid:aid:ext:ver # root artifact asdf:qwer:zcxv:uip";
DependencyNode node = parser.parseLiteral(def);
assertNodeProperties(node, "");
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class DependencyGraphParserTest method testWithChildren.
@Test
public void testWithChildren() throws IOException {
String def = "gid1:aid1:ext1:ver1:scope1\n" + "+- gid2:aid2:ext2:ver2:scope2\n" + "\\- gid3:aid3:ext3:ver3:scope3\n";
DependencyNode node = parser.parseLiteral(def);
assertNotNull(node);
int idx = 1;
assertNodeProperties(node, idx++);
List<DependencyNode> children = node.getChildren();
assertEquals(2, children.size());
for (DependencyNode child : children) {
assertNodeProperties(child, idx++);
}
}
Aggregations