Search in sources :

Example 6 with DefaultArtifact

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

the class SimpleLocalRepositoryManagerTest method testGetPathForLocalArtifact.

@Test
public void testGetPathForLocalArtifact() throws Exception {
    Artifact artifact = new DefaultArtifact("g.i.d:a.i.d:1.0-SNAPSHOT");
    assertEquals("1.0-SNAPSHOT", artifact.getBaseVersion());
    assertEquals("g/i/d/a.i.d/1.0-SNAPSHOT/a.i.d-1.0-SNAPSHOT.jar", manager.getPathForLocalArtifact(artifact));
    artifact = new DefaultArtifact("g.i.d:a.i.d:1.0-20110329.221805-4");
    assertEquals("1.0-SNAPSHOT", artifact.getBaseVersion());
    assertEquals("g/i/d/a.i.d/1.0-SNAPSHOT/a.i.d-1.0-SNAPSHOT.jar", manager.getPathForLocalArtifact(artifact));
    artifact = new DefaultArtifact("g.i.d", "a.i.d", "", "", "1.0-SNAPSHOT");
    assertEquals("g/i/d/a.i.d/1.0-SNAPSHOT/a.i.d-1.0-SNAPSHOT", manager.getPathForLocalArtifact(artifact));
}
Also used : Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) Test(org.junit.Test)

Example 7 with DefaultArtifact

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

the class SimpleLocalRepositoryManagerTest method testGetPathForRemoteArtifact.

@Test
public void testGetPathForRemoteArtifact() throws Exception {
    RemoteRepository remoteRepo = new RemoteRepository("repo", "default", "ram:/void");
    Artifact artifact = new DefaultArtifact("g.i.d:a.i.d:1.0-SNAPSHOT");
    assertEquals("1.0-SNAPSHOT", artifact.getBaseVersion());
    assertEquals("g/i/d/a.i.d/1.0-SNAPSHOT/a.i.d-1.0-SNAPSHOT.jar", manager.getPathForRemoteArtifact(artifact, remoteRepo, ""));
    artifact = new DefaultArtifact("g.i.d:a.i.d:1.0-20110329.221805-4");
    assertEquals("1.0-SNAPSHOT", artifact.getBaseVersion());
    assertEquals("g/i/d/a.i.d/1.0-SNAPSHOT/a.i.d-1.0-20110329.221805-4.jar", manager.getPathForRemoteArtifact(artifact, remoteRepo, ""));
}
Also used : RemoteRepository(org.sonatype.aether.repository.RemoteRepository) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) Test(org.junit.Test)

Example 8 with DefaultArtifact

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

the class EnhancedLocalRepositoryManagerTest method setup.

@Before
public void setup() throws Exception {
    repository = new RemoteRepository("enhanced-remote-repo", "default", TestFileUtils.createTempDir("enhanced-remote-repo").toURI().toURL().toString());
    repository.setRepositoryManager(true);
    artifact = new DefaultArtifact("gid", "aid", "", "jar", "1-test", Collections.<String, String>emptyMap(), TestFileUtils.createTempFile("artifact"));
    metadata = new DefaultMetadata("gid", "aid", "1-test", "maven-metadata.xml", Nature.RELEASE, TestFileUtils.createTempFile("metadata"));
    noVerMetadata = new DefaultMetadata("gid", "aid", null, "maven-metadata.xml", Nature.RELEASE, TestFileUtils.createTempFile("metadata"));
    basedir = TestFileUtils.createTempDir("enhanced-repo");
    manager = new EnhancedLocalRepositoryManager(basedir);
    artifactFile = new File(basedir, manager.getPathForLocalArtifact(artifact));
    session = new TestRepositorySystemSession();
}
Also used : TestRepositorySystemSession(org.sonatype.aether.test.impl.TestRepositorySystemSession) DefaultMetadata(org.sonatype.aether.util.metadata.DefaultMetadata) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) File(java.io.File) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) Before(org.junit.Before)

Example 9 with DefaultArtifact

use of org.sonatype.aether.util.artifact.DefaultArtifact 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 10 with DefaultArtifact

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

the class FindNewestVersion method main.

public static void main(String[] args) throws Exception {
    System.out.println("------------------------------------------------------------");
    System.out.println(FindNewestVersion.class.getSimpleName());
    RepositorySystem system = Booter.newRepositorySystem();
    RepositorySystemSession session = Booter.newRepositorySystemSession(system);
    Artifact artifact = new DefaultArtifact("org.sonatype.aether:aether-util:[0,)");
    RemoteRepository repo = Booter.newCentralRepository();
    VersionRangeRequest rangeRequest = new VersionRangeRequest();
    rangeRequest.setArtifact(artifact);
    rangeRequest.addRepository(repo);
    VersionRangeResult rangeResult = system.resolveVersionRange(session, rangeRequest);
    Version newestVersion = rangeResult.getHighestVersion();
    System.out.println("Newest version " + newestVersion + " from repository " + rangeResult.getRepository(newestVersion));
}
Also used : RepositorySystem(org.sonatype.aether.RepositorySystem) RepositorySystemSession(org.sonatype.aether.RepositorySystemSession) VersionRangeResult(org.sonatype.aether.resolution.VersionRangeResult) Version(org.sonatype.aether.version.Version) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) VersionRangeRequest(org.sonatype.aether.resolution.VersionRangeRequest) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact)

Aggregations

DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)33 Artifact (org.sonatype.aether.artifact.Artifact)23 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)18 Test (org.junit.Test)10 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)10 File (java.io.File)9 RepositorySystem (org.sonatype.aether.RepositorySystem)9 Dependency (org.sonatype.aether.graph.Dependency)9 CollectRequest (org.sonatype.aether.collection.CollectRequest)8 DependencyRequest (org.sonatype.aether.resolution.DependencyRequest)6 DependencyFilter (org.sonatype.aether.graph.DependencyFilter)5 ArtifactResult (org.sonatype.aether.resolution.ArtifactResult)4 PatternExclusionsDependencyFilter (org.sonatype.aether.util.filter.PatternExclusionsDependencyFilter)4 Before (org.junit.Before)3 TestRepositorySystemSession (org.sonatype.aether.test.impl.TestRepositorySystemSession)3 SubArtifact (org.sonatype.aether.util.artifact.SubArtifact)3 DefaultMetadata (org.sonatype.aether.util.metadata.DefaultMetadata)3 ConsoleDependencyGraphDumper (demo.util.ConsoleDependencyGraphDumper)2 CollectResult (org.sonatype.aether.collection.CollectResult)2 DeployRequest (org.sonatype.aether.deployment.DeployRequest)2