Search in sources :

Example 1 with SubArtifact

use of org.sonatype.aether.util.artifact.SubArtifact in project sonatype-aether by sonatype.

the class DeployArtifacts method main.

public static void main(String[] args) throws Exception {
    System.out.println("------------------------------------------------------------");
    System.out.println(DeployArtifacts.class.getSimpleName());
    RepositorySystem system = Booter.newRepositorySystem();
    RepositorySystemSession session = Booter.newRepositorySystemSession(system);
    Artifact jarArtifact = new DefaultArtifact("test", "demo", "", "jar", "0.1-SNAPSHOT");
    jarArtifact = jarArtifact.setFile(new File("demo.jar"));
    Artifact pomArtifact = new SubArtifact(jarArtifact, "", "pom");
    pomArtifact = pomArtifact.setFile(new File("pom.xml"));
    RemoteRepository distRepo = new RemoteRepository("demo", "default", new File("target/dist-repo").toURI().toString());
    DeployRequest deployRequest = new DeployRequest();
    deployRequest.addArtifact(jarArtifact).addArtifact(pomArtifact);
    deployRequest.setRepository(distRepo);
    system.deploy(session, deployRequest);
}
Also used : RepositorySystem(org.sonatype.aether.RepositorySystem) RepositorySystemSession(org.sonatype.aether.RepositorySystemSession) SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) DeployRequest(org.sonatype.aether.deployment.DeployRequest) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact)

Example 2 with SubArtifact

use of org.sonatype.aether.util.artifact.SubArtifact in project sonatype-aether by sonatype.

the class InstallArtifacts method main.

public static void main(String[] args) throws Exception {
    System.out.println("------------------------------------------------------------");
    System.out.println(InstallArtifacts.class.getSimpleName());
    RepositorySystem system = Booter.newRepositorySystem();
    RepositorySystemSession session = Booter.newRepositorySystemSession(system);
    Artifact jarArtifact = new DefaultArtifact("test", "demo", "", "jar", "0.1-SNAPSHOT");
    jarArtifact = jarArtifact.setFile(new File("demo.jar"));
    Artifact pomArtifact = new SubArtifact(jarArtifact, "", "pom");
    pomArtifact = pomArtifact.setFile(new File("pom.xml"));
    InstallRequest installRequest = new InstallRequest();
    installRequest.addArtifact(jarArtifact).addArtifact(pomArtifact);
    system.install(session, installRequest);
}
Also used : RepositorySystem(org.sonatype.aether.RepositorySystem) RepositorySystemSession(org.sonatype.aether.RepositorySystemSession) InstallRequest(org.sonatype.aether.installation.InstallRequest) SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact)

Example 3 with SubArtifact

use of org.sonatype.aether.util.artifact.SubArtifact in project sonatype-aether by sonatype.

the class AetherDemo method installAndDeploy.

public void installAndDeploy() throws InstallationException, DeploymentException {
    Aether aether = new Aether("http://localhost:8081/nexus/content/groups/public", "/Users/jvanzyl/aether-repo");
    Artifact artifact = new DefaultArtifact("com.mycompany.super", "super-core", "jar", "0.1-SNAPSHOT");
    artifact = artifact.setFile(new File("jar-from-whatever-process.jar"));
    Artifact pom = new SubArtifact(artifact, null, "pom");
    pom = pom.setFile(new File("pom-from-whatever-process.xml"));
    // Install into the local repository specified
    // 
    aether.install(artifact, pom);
    // Deploy to a remote reposistory
    // 
    aether.deploy(artifact, pom, "http://localhost:8081/nexus/content/repositories/snapshots/");
}
Also used : SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact)

Example 4 with SubArtifact

use of org.sonatype.aether.util.artifact.SubArtifact in project sonatype-aether by sonatype.

the class SubArtifactTest method testEmptyClassifier.

@Test
public void testEmptyClassifier() {
    Artifact main = newMainArtifact("gid:aid:ext:cls:ver");
    Artifact sub = new SubArtifact(main, "", "pom");
    assertEquals("", sub.getClassifier());
    sub = new SubArtifact(main, null, "pom");
    assertEquals("", sub.getClassifier());
}
Also used : SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) Artifact(org.sonatype.aether.artifact.Artifact) SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) Test(org.junit.Test)

Example 5 with SubArtifact

use of org.sonatype.aether.util.artifact.SubArtifact in project sonatype-aether by sonatype.

the class SubArtifactTest method testImmutability.

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

Aggregations

Artifact (org.sonatype.aether.artifact.Artifact)13 SubArtifact (org.sonatype.aether.util.artifact.SubArtifact)13 Test (org.junit.Test)10 File (java.io.File)5 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)3 RepositorySystem (org.sonatype.aether.RepositorySystem)2 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)2 HashMap (java.util.HashMap)1 DeployRequest (org.sonatype.aether.deployment.DeployRequest)1 InstallRequest (org.sonatype.aether.installation.InstallRequest)1 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)1