Search in sources :

Example 6 with StubArtifact

use of org.sonatype.aether.test.util.impl.StubArtifact 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 7 with StubArtifact

use of org.sonatype.aether.test.util.impl.StubArtifact in project sonatype-aether by sonatype.

the class MavenDefaultLayoutTest method testArtifactPath.

@Test
public void testArtifactPath() {
    MavenDefaultLayout layout = new MavenDefaultLayout();
    URI uri = layout.getPath(new StubArtifact("g.i.d", "a-i.d", "cls", "ext", "1.0"));
    assertEquals("g/i/d/a-i.d/1.0/a-i.d-1.0-cls.ext", uri.getPath());
    uri = layout.getPath(new StubArtifact("g.i.d", "aid", "", "ext", "1.0"));
    assertEquals("g/i/d/aid/1.0/aid-1.0.ext", uri.getPath());
    uri = layout.getPath(new StubArtifact("g.i.d", "aid", "", "", "1.0"));
    assertEquals("g/i/d/aid/1.0/aid-1.0", uri.getPath());
}
Also used : StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) URI(java.net.URI) Test(org.junit.Test)

Example 8 with StubArtifact

use of org.sonatype.aether.test.util.impl.StubArtifact in project sonatype-aether by sonatype.

the class IniArtifactDataReader method relocations.

private List<Artifact> relocations(List<String> list) {
    List<Artifact> ret = new ArrayList<Artifact>();
    if (list == null) {
        return ret;
    }
    for (String coords : list) {
        ArtifactDefinition def = new ArtifactDefinition(coords);
        ret.add(new StubArtifact(def.getGroupId(), def.getArtifactId(), "", def.getExtension(), def.getVersion()));
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) Artifact(org.sonatype.aether.artifact.Artifact)

Example 9 with StubArtifact

use of org.sonatype.aether.test.util.impl.StubArtifact in project sonatype-aether by sonatype.

the class IniArtifactDataReader method dependencies.

private List<Dependency> dependencies(List<String> list) {
    List<Dependency> ret = new ArrayList<Dependency>();
    if (list == null) {
        return ret;
    }
    Collection<Exclusion> exclusions = new ArrayList<Exclusion>();
    boolean optional = false;
    Artifact artifact = null;
    String scope = null;
    for (String coords : list) {
        if (coords.startsWith("-")) {
            coords = coords.substring(1);
            String[] split = coords.split(":");
            exclusions.add(new Exclusion(split[0], split[1], "", ""));
        } else {
            if (artifact != null) {
                // commit dependency
                Dependency dep = new Dependency(artifact, scope, optional, exclusions);
                ret.add(dep);
                exclusions = new ArrayList<Exclusion>();
            }
            ArtifactDefinition def = new ArtifactDefinition(coords);
            optional = def.isOptional();
            scope = "".equals(def.getScope()) ? "compile" : def.getScope();
            artifact = new StubArtifact(def.getGroupId(), def.getArtifactId(), "", def.getExtension(), def.getVersion());
        }
    }
    if (artifact != null) {
        // commit dependency
        Dependency dep = new Dependency(artifact, scope, optional, exclusions);
        ret.add(dep);
        exclusions = new ArrayList<Exclusion>();
    }
    return ret;
}
Also used : Exclusion(org.sonatype.aether.graph.Exclusion) ArrayList(java.util.ArrayList) StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) Dependency(org.sonatype.aether.graph.Dependency) StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) Artifact(org.sonatype.aether.artifact.Artifact)

Example 10 with StubArtifact

use of org.sonatype.aether.test.util.impl.StubArtifact in project sonatype-aether by sonatype.

the class NodeBuilder method build.

public DependencyNode build() {
    Dependency dependency = null;
    TestDependencyNode node = new TestDependencyNode();
    if (artifactId != null && artifactId.length() > 0) {
        Artifact artifact = new StubArtifact(groupId, artifactId, classifier, ext, version, properties);
        dependency = new Dependency(artifact, scope, optional);
        node.setDependency(dependency);
        try {
            node.setVersion(versionScheme.parseVersion(version));
            node.setVersionConstraint(versionScheme.parseVersionConstraint(range != null ? range : version));
        } catch (InvalidVersionSpecificationException e) {
            throw new IllegalArgumentException("bad version: " + e.getMessage(), e);
        }
    }
    node.setRequestContext(context);
    node.setRelocations(relocations);
    return node;
}
Also used : TestDependencyNode(org.sonatype.aether.test.util.impl.TestDependencyNode) InvalidVersionSpecificationException(org.sonatype.aether.version.InvalidVersionSpecificationException) StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) Dependency(org.sonatype.aether.graph.Dependency) StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) Artifact(org.sonatype.aether.artifact.Artifact)

Aggregations

StubArtifact (org.sonatype.aether.test.util.impl.StubArtifact)17 Test (org.junit.Test)8 Artifact (org.sonatype.aether.artifact.Artifact)8 StubMetadata (org.sonatype.aether.test.util.impl.StubMetadata)7 File (java.io.File)6 ArtifactDownload (org.sonatype.aether.spi.connector.ArtifactDownload)6 ArtifactUpload (org.sonatype.aether.spi.connector.ArtifactUpload)6 MetadataDownload (org.sonatype.aether.spi.connector.MetadataDownload)5 MetadataUpload (org.sonatype.aether.spi.connector.MetadataUpload)5 Before (org.junit.Before)4 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)4 RepositoryConnector (org.sonatype.aether.spi.connector.RepositoryConnector)4 TestRepositorySystemSession (org.sonatype.aether.test.impl.TestRepositorySystemSession)4 ArrayList (java.util.ArrayList)3 Metadata (org.sonatype.aether.metadata.Metadata)3 TestFileProcessor (org.sonatype.aether.test.impl.TestFileProcessor)3 Dependency (org.sonatype.aether.graph.Dependency)2 ArtifactDescriptorRequest (org.sonatype.aether.resolution.ArtifactDescriptorRequest)2 SysoutLogger (org.sonatype.aether.test.impl.SysoutLogger)2 IOException (java.io.IOException)1