Search in sources :

Example 1 with DependencyNode

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();
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) Artifact(org.sonatype.aether.artifact.Artifact)

Example 2 with DependencyNode

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));
}
Also used : CollectResult(org.sonatype.aether.collection.CollectResult) DependencyNode(org.sonatype.aether.graph.DependencyNode) Dependency(org.sonatype.aether.graph.Dependency) CollectRequest(org.sonatype.aether.collection.CollectRequest) Test(org.junit.Test)

Example 3 with DependencyNode

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());
}
Also used : CollectResult(org.sonatype.aether.collection.CollectResult) DependencyNode(org.sonatype.aether.graph.DependencyNode) Dependency(org.sonatype.aether.graph.Dependency) CollectRequest(org.sonatype.aether.collection.CollectRequest) Test(org.junit.Test)

Example 4 with DependencyNode

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, "");
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) Test(org.junit.Test)

Example 5 with DependencyNode

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++);
    }
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) Test(org.junit.Test)

Aggregations

DependencyNode (org.sonatype.aether.graph.DependencyNode)114 Test (org.junit.Test)82 NodeBuilder (org.sonatype.aether.test.util.NodeBuilder)20 Dependency (org.sonatype.aether.graph.Dependency)14 IdentityHashMap (java.util.IdentityHashMap)13 CollectRequest (org.sonatype.aether.collection.CollectRequest)12 CollectResult (org.sonatype.aether.collection.CollectResult)11 List (java.util.List)8 Map (java.util.Map)8 LinkedList (java.util.LinkedList)7 Artifact (org.sonatype.aether.artifact.Artifact)6 DependencyFilter (org.sonatype.aether.graph.DependencyFilter)5 ArrayList (java.util.ArrayList)4 DependencyGraphTransformationContext (org.sonatype.aether.collection.DependencyGraphTransformationContext)4 ConflictMarker (org.sonatype.aether.util.graph.transformer.ConflictMarker)4 HashMap (java.util.HashMap)3 ArtifactDescriptorException (org.sonatype.aether.resolution.ArtifactDescriptorException)3 BufferedReader (java.io.BufferedReader)2 HashSet (java.util.HashSet)2 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)2