Search in sources :

Example 36 with Artifact

use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.

the class ConflictMarker method getKeys.

private Set<Object> getKeys(DependencyNode node) {
    Set<Object> keys;
    Dependency dependency = node.getDependency();
    if (dependency == null) {
        keys = Collections.emptySet();
    } else {
        Object key = toKey(dependency.getArtifact());
        if (node.getRelocations().isEmpty() && node.getAliases().isEmpty()) {
            keys = Collections.singleton(key);
        } else {
            keys = new HashSet<Object>();
            keys.add(key);
            for (Artifact relocation : node.getRelocations()) {
                key = toKey(relocation);
                keys.add(key);
            }
            for (Artifact alias : node.getAliases()) {
                key = toKey(alias);
                keys.add(key);
            }
        }
    }
    return keys;
}
Also used : Dependency(org.sonatype.aether.graph.Dependency) Artifact(org.sonatype.aether.artifact.Artifact)

Example 37 with Artifact

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

Example 38 with Artifact

use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.

the class ArtifacIdUtilsTest method testToBaseIdArtifact.

@Test
public void testToBaseIdArtifact() {
    Artifact artifact = null;
    assertSame(null, ArtifacIdUtils.toBaseId(artifact));
    artifact = new DefaultArtifact("gid", "aid", "ext", "1.0-20110205.132618-23");
    assertEquals("gid:aid:ext:1.0-SNAPSHOT", ArtifacIdUtils.toBaseId(artifact));
    artifact = new DefaultArtifact("gid", "aid", "cls", "ext", "1.0-20110205.132618-23");
    assertEquals("gid:aid:ext:cls:1.0-SNAPSHOT", ArtifacIdUtils.toBaseId(artifact));
}
Also used : Artifact(org.sonatype.aether.artifact.Artifact) Test(org.junit.Test)

Example 39 with Artifact

use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.

the class ArtifacIdUtilsTest method testToVersionlessIdArtifact.

@Test
public void testToVersionlessIdArtifact() {
    Artifact artifact = null;
    assertSame(null, ArtifacIdUtils.toId(artifact));
    artifact = new DefaultArtifact("gid", "aid", "ext", "1");
    assertEquals("gid:aid:ext", ArtifacIdUtils.toVersionlessId(artifact));
    artifact = new DefaultArtifact("gid", "aid", "cls", "ext", "1");
    assertEquals("gid:aid:ext:cls", ArtifacIdUtils.toVersionlessId(artifact));
}
Also used : Artifact(org.sonatype.aether.artifact.Artifact) Test(org.junit.Test)

Example 40 with Artifact

use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.

the class DefaultArtifactTest method testPropertiesCopied.

@Test
public void testPropertiesCopied() {
    Map<String, String> props = new HashMap<String, String>();
    props.put("key", "value1");
    Artifact a = new DefaultArtifact("gid:aid:1", props);
    assertEquals("value1", a.getProperty("key", null));
    props.clear();
    assertEquals("value1", a.getProperty("key", null));
    props.put("key", "value2");
    a = a.setProperties(props);
    assertEquals("value2", a.getProperty("key", null));
    props.clear();
    assertEquals("value2", a.getProperty("key", null));
}
Also used : HashMap(java.util.HashMap) Artifact(org.sonatype.aether.artifact.Artifact) Test(org.junit.Test)

Aggregations

Artifact (org.sonatype.aether.artifact.Artifact)116 Test (org.junit.Test)63 File (java.io.File)33 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)30 StubArtifact (org.sonatype.aether.test.util.impl.StubArtifact)28 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)27 Dependency (org.sonatype.aether.graph.Dependency)22 ArtifactResult (org.sonatype.aether.resolution.ArtifactResult)17 ArtifactDownload (org.sonatype.aether.spi.connector.ArtifactDownload)16 LocalArtifactRequest (org.sonatype.aether.repository.LocalArtifactRequest)15 LocalArtifactResult (org.sonatype.aether.repository.LocalArtifactResult)15 ArtifactRequest (org.sonatype.aether.resolution.ArtifactRequest)14 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)13 SubArtifact (org.sonatype.aether.util.artifact.SubArtifact)13 ArrayList (java.util.ArrayList)12 ArtifactTransferException (org.sonatype.aether.transfer.ArtifactTransferException)12 Metadata (org.sonatype.aether.metadata.Metadata)10 RepositorySystem (org.sonatype.aether.RepositorySystem)9 IOException (java.io.IOException)8 HashMap (java.util.HashMap)8