Search in sources :

Example 51 with Artifact

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

the class NodeBuilder method reloc.

public NodeBuilder reloc(String artifactId) {
    Artifact relocation = new StubArtifact(groupId, artifactId, classifier, ext, version);
    relocations.add(relocation);
    return this;
}
Also used : StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) Artifact(org.sonatype.aether.artifact.Artifact)

Example 52 with Artifact

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

the class DefaultArtifactTest method testImmutability.

@Test
public void testImmutability() {
    Artifact a = new DefaultArtifact("gid:aid:ext:cls:ver");
    assertNotSame(a, a.setFile(new File("file")));
    assertNotSame(a, a.setVersion("otherVersion"));
    assertNotSame(a, a.setProperties(Collections.singletonMap("key", "value")));
}
Also used : File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact) Test(org.junit.Test)

Example 53 with Artifact

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

the class DefaultArtifactTest method testArtifactType.

@Test
public void testArtifactType() {
    DefaultArtifactType type = new DefaultArtifactType("typeId", "typeExt", "typeCls", "typeLang", true, true);
    Artifact a = new DefaultArtifact("gid", "aid", null, null, null, null, type);
    assertEquals("typeExt", a.getExtension());
    assertEquals("typeCls", a.getClassifier());
    assertEquals("typeLang", a.getProperties().get(ArtifactProperties.LANGUAGE));
    assertEquals("typeId", a.getProperties().get(ArtifactProperties.TYPE));
    assertEquals("true", a.getProperties().get(ArtifactProperties.INCLUDES_DEPENDENCIES));
    assertEquals("true", a.getProperties().get(ArtifactProperties.CONSTITUTES_BUILD_PATH));
    a = new DefaultArtifact("gid", "aid", "cls", "ext", "ver", null, type);
    assertEquals("ext", a.getExtension());
    assertEquals("cls", a.getClassifier());
    assertEquals("typeLang", a.getProperties().get(ArtifactProperties.LANGUAGE));
    assertEquals("typeId", a.getProperties().get(ArtifactProperties.TYPE));
    assertEquals("true", a.getProperties().get(ArtifactProperties.INCLUDES_DEPENDENCIES));
    assertEquals("true", a.getProperties().get(ArtifactProperties.CONSTITUTES_BUILD_PATH));
    Map<String, String> props = new HashMap<String, String>();
    props.put("someNonStandardProperty", "someNonStandardProperty");
    a = new DefaultArtifact("gid", "aid", "cls", "ext", "ver", props, type);
    assertEquals("ext", a.getExtension());
    assertEquals("cls", a.getClassifier());
    assertEquals("typeLang", a.getProperties().get(ArtifactProperties.LANGUAGE));
    assertEquals("typeId", a.getProperties().get(ArtifactProperties.TYPE));
    assertEquals("true", a.getProperties().get(ArtifactProperties.INCLUDES_DEPENDENCIES));
    assertEquals("true", a.getProperties().get(ArtifactProperties.CONSTITUTES_BUILD_PATH));
    assertEquals("someNonStandardProperty", a.getProperties().get("someNonStandardProperty"));
    props = new HashMap<String, String>();
    props.put("someNonStandardProperty", "someNonStandardProperty");
    props.put(ArtifactProperties.CONSTITUTES_BUILD_PATH, "rubbish");
    props.put(ArtifactProperties.INCLUDES_DEPENDENCIES, "rubbish");
    a = new DefaultArtifact("gid", "aid", "cls", "ext", "ver", props, type);
    assertEquals("ext", a.getExtension());
    assertEquals("cls", a.getClassifier());
    assertEquals("typeLang", a.getProperties().get(ArtifactProperties.LANGUAGE));
    assertEquals("typeId", a.getProperties().get(ArtifactProperties.TYPE));
    assertEquals("rubbish", a.getProperties().get(ArtifactProperties.INCLUDES_DEPENDENCIES));
    assertEquals("rubbish", a.getProperties().get(ArtifactProperties.CONSTITUTES_BUILD_PATH));
    assertEquals("someNonStandardProperty", a.getProperties().get("someNonStandardProperty"));
}
Also used : HashMap(java.util.HashMap) Artifact(org.sonatype.aether.artifact.Artifact) Test(org.junit.Test)

Example 54 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)

Example 55 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)

Aggregations

Artifact (org.sonatype.aether.artifact.Artifact)116 Test (org.junit.Test)62 File (java.io.File)34 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)33 StubArtifact (org.sonatype.aether.test.util.impl.StubArtifact)28 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)28 Dependency (org.sonatype.aether.graph.Dependency)21 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)15 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)13 SubArtifact (org.sonatype.aether.util.artifact.SubArtifact)13 ArtifactTransferException (org.sonatype.aether.transfer.ArtifactTransferException)12 ArrayList (java.util.ArrayList)11 RepositorySystem (org.sonatype.aether.RepositorySystem)10 Metadata (org.sonatype.aether.metadata.Metadata)10 CollectRequest (org.sonatype.aether.collection.CollectRequest)9 IOException (java.io.IOException)8