use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class NearestVersionConflictResolverTest method testNearestSoftVersionPrunedByFartherRange.
@Test
public void testNearestSoftVersionPrunedByFartherRange() throws Exception {
// root
// +- a:1
// | \- c:2
// \- b:1
// \- c:[1]
DependencyNode a = builder.artifactId("a").version("1").build();
DependencyNode b = builder.artifactId("b").version("1").build();
DependencyNode c1 = builder.artifactId("c").version("1").range("[1]").build();
DependencyNode c2 = builder.artifactId("c").version("2").build();
a.getChildren().add(c2);
b.getChildren().add(c1);
DependencyNode root = builder.artifactId(null).build();
root.getChildren().add(a);
root.getChildren().add(b);
Map<DependencyNode, Object> conflictIds = new IdentityHashMap<DependencyNode, Object>();
conflictIds.put(a, "a");
conflictIds.put(b, "b");
conflictIds.put(c1, "c");
conflictIds.put(c2, "c");
context.put(TransformationContextKeys.CONFLICT_IDS, conflictIds);
NearestVersionConflictResolver transformer = new NearestVersionConflictResolver();
root = transformer.transformGraph(root, context);
assertEquals(2, root.getChildren().size());
assertSame(a, root.getChildren().get(0));
assertSame(b, root.getChildren().get(1));
assertTrue(a.getChildren().isEmpty());
assertEquals(1, b.getChildren().size());
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class SimpleConflictMarker method mark.
private void mark(DependencyNode node, Map<DependencyNode, Object> conflictIds) {
Dependency dependency = node.getDependency();
if (dependency != null) {
Artifact artifact = dependency.getArtifact();
String key = String.format("%s:%s:%s:%s", artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getExtension());
if (conflictIds.put(node, key) != null) {
return;
}
}
for (DependencyNode child : node.getChildren()) {
mark(child, conflictIds);
}
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class JavaDependencyContextRefinerTest method testRefineToTest.
@Test
public void testRefineToTest() throws IOException, RepositoryException {
String expected = "project/test";
DependencyNode node = parser.parseLiteral("gid:aid:ext:ver:test");
node.setRequestContext("project");
DependencyNode refinedNode = refiner.transformGraph(node, context);
assertEquals(expected, refinedNode.getRequestContext());
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class JavaEffectiveScopeCalculatorTest method testScopeOfDirectDependencyWinsConflictAndGetsUsedForInheritanceToChildrenEverywhereInGraph.
@Test
public void testScopeOfDirectDependencyWinsConflictAndGetsUsedForInheritanceToChildrenEverywhereInGraph() throws Exception {
DependencyNode root = parser.parse("direct-with-conflict-and-inheritance.txt");
root = transform(root);
expectScope("test", root, 0, 0);
expectScope("test", root, 1, 0, 0);
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class JavaEffectiveScopeCalculatorTest method testDirectNodesAlwaysWin.
@Test
public void testDirectNodesAlwaysWin() throws IOException, RepositoryException {
for (Scope directScope : Scope.values()) {
String direct = directScope.toString();
parser.setSubstitutions(direct);
DependencyNode root = parser.parse("direct-nodes-winning.txt");
String msg = String.format("direct node should be setting scope ('%s') for all nodes.\n" + parser.dump(root), direct);
root = transform(root);
msg += "\ntransformed:\n" + parser.dump(root);
expectScope(msg, direct, root, 0);
expectScope(msg, direct, root, 1, 0);
expectScope(msg, direct, root, 2, 0);
expectScope(msg, direct, root, 3, 0);
expectScope(msg, direct, root, 4, 0);
}
}
Aggregations