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));
}
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, ""));
}
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();
}
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);
}
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));
}
Aggregations