use of org.sonatype.aether.artifact.Artifact 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.artifact.Artifact in project sonatype-aether by sonatype.
the class DependencyGraphParser method addNode.
private void addNode(DependencyNode root, int level, List<NodeEntry> entries) {
NodeEntry entry = new NodeEntry();
Dependency dependency = root.getDependency();
StringBuilder defBuilder = new StringBuilder();
if (dependency == null) {
defBuilder.append("(null)");
} else {
Artifact artifact = dependency.getArtifact();
defBuilder.append(artifact.getGroupId()).append(":").append(artifact.getArtifactId()).append(":").append(artifact.getExtension()).append(":").append(artifact.getVersion());
if (dependency.getScope() != null && (!"".equals(dependency.getScope()))) {
defBuilder.append(":").append(dependency.getScope());
}
Map<String, String> properties = artifact.getProperties();
if (!(properties == null || properties.isEmpty())) {
for (Map.Entry<String, String> prop : properties.entrySet()) {
defBuilder.append(";").append(prop.getKey()).append("=").append(prop.getValue());
}
}
}
entry.setDefinition(defBuilder.toString());
entry.setLevel(level++);
entries.add(entry);
for (DependencyNode node : root.getChildren()) {
addNode(node, level, entries);
}
}
use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.
the class DependencyGraphParserTest method testOnlyRoot.
@Test
public void testOnlyRoot() throws IOException {
String def = "gid:aid:jar:1:scope";
DependencyNode node = parser.parseLiteral(def);
assertNotNull(node);
assertEquals(0, node.getChildren().size());
Dependency dependency = node.getDependency();
assertNotNull(dependency);
assertEquals("scope", dependency.getScope());
Artifact artifact = dependency.getArtifact();
assertNotNull(artifact);
assertEquals("gid", artifact.getGroupId());
assertEquals("aid", artifact.getArtifactId());
assertEquals("jar", artifact.getExtension());
assertEquals("1", artifact.getVersion());
}
use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.
the class IniArtifactDataReaderTest method testRelocations.
@Test
public void testRelocations() throws IOException {
String def = "[relocations]\ngid:aid:ext:ver\ngid2:aid2:ext2:ver2";
ArtifactDescription description = parser.parseLiteral(def);
List<Artifact> relocations = description.getRelocations();
assertNotNull(relocations);
assertEquals(2, relocations.size());
Artifact artifact = relocations.get(0);
assertEquals("aid", artifact.getArtifactId());
assertEquals("gid", artifact.getGroupId());
assertEquals("ver", artifact.getVersion());
assertEquals("ext", artifact.getExtension());
artifact = relocations.get(1);
assertEquals("aid2", artifact.getArtifactId());
assertEquals("gid2", artifact.getGroupId());
assertEquals("ver2", artifact.getVersion());
assertEquals("ext2", artifact.getExtension());
}
use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.
the class IniArtifactDescriptorReaderTest method assertDependencies.
private void assertDependencies(List<Dependency> deps) {
assertEquals(4, deps.size());
Dependency dep = deps.get(0);
assertEquals("scope", dep.getScope());
assertEquals(false, dep.isOptional());
assertEquals(2, dep.getExclusions().size());
Iterator<Exclusion> it = dep.getExclusions().iterator();
Exclusion excl = it.next();
assertEquals("gid3", excl.getGroupId());
assertEquals("aid", excl.getArtifactId());
excl = it.next();
assertEquals("gid2", excl.getGroupId());
assertEquals("aid2", excl.getArtifactId());
Artifact art = dep.getArtifact();
assertEquals("gid", art.getGroupId());
assertEquals("aid", art.getArtifactId());
assertEquals("ver", art.getVersion());
assertEquals("ext", art.getExtension());
dep = deps.get(1);
assertEquals("scope", dep.getScope());
assertEquals(true, dep.isOptional());
assertEquals(0, dep.getExclusions().size());
art = dep.getArtifact();
assertEquals("gid", art.getGroupId());
assertEquals("aid2", art.getArtifactId());
assertEquals("ver", art.getVersion());
assertEquals("ext", art.getExtension());
dep = deps.get(2);
assertEquals("scope", dep.getScope());
assertEquals(true, dep.isOptional());
assertEquals(0, dep.getExclusions().size());
art = dep.getArtifact();
assertEquals("gid", art.getGroupId());
assertEquals("aid", art.getArtifactId());
assertEquals("ver3", art.getVersion());
assertEquals("ext", art.getExtension());
dep = deps.get(3);
assertEquals("scope5", dep.getScope());
assertEquals(true, dep.isOptional());
assertEquals(0, dep.getExclusions().size());
art = dep.getArtifact();
assertEquals("gid1", art.getGroupId());
assertEquals("aid", art.getArtifactId());
assertEquals("ver", art.getVersion());
assertEquals("ext", art.getExtension());
}
Aggregations