use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.
the class ConflictMarker method getKeys.
private Set<Object> getKeys(DependencyNode node) {
Set<Object> keys;
Dependency dependency = node.getDependency();
if (dependency == null) {
keys = Collections.emptySet();
} else {
Object key = toKey(dependency.getArtifact());
if (node.getRelocations().isEmpty() && node.getAliases().isEmpty()) {
keys = Collections.singleton(key);
} else {
keys = new HashSet<Object>();
keys.add(key);
for (Artifact relocation : node.getRelocations()) {
key = toKey(relocation);
keys.add(key);
}
for (Artifact alias : node.getAliases()) {
key = toKey(alias);
keys.add(key);
}
}
}
return keys;
}
use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.
the class SimpleConflictMarker method mark.
private void mark(DependencyNode node, Map<DependencyNode, Object> conflictIds) {
Dependency dependency = node.getDependency();
if (dependency != null) {
Artifact artifact = dependency.getArtifact();
String key = String.format("%s:%s:%s:%s", artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getExtension());
if (conflictIds.put(node, key) != null) {
return;
}
}
for (DependencyNode child : node.getChildren()) {
mark(child, conflictIds);
}
}
use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.
the class ArtifacIdUtilsTest method testToBaseIdArtifact.
@Test
public void testToBaseIdArtifact() {
Artifact artifact = null;
assertSame(null, ArtifacIdUtils.toBaseId(artifact));
artifact = new DefaultArtifact("gid", "aid", "ext", "1.0-20110205.132618-23");
assertEquals("gid:aid:ext:1.0-SNAPSHOT", ArtifacIdUtils.toBaseId(artifact));
artifact = new DefaultArtifact("gid", "aid", "cls", "ext", "1.0-20110205.132618-23");
assertEquals("gid:aid:ext:cls:1.0-SNAPSHOT", ArtifacIdUtils.toBaseId(artifact));
}
use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.
the class ArtifacIdUtilsTest method testToVersionlessIdArtifact.
@Test
public void testToVersionlessIdArtifact() {
Artifact artifact = null;
assertSame(null, ArtifacIdUtils.toId(artifact));
artifact = new DefaultArtifact("gid", "aid", "ext", "1");
assertEquals("gid:aid:ext", ArtifacIdUtils.toVersionlessId(artifact));
artifact = new DefaultArtifact("gid", "aid", "cls", "ext", "1");
assertEquals("gid:aid:ext:cls", ArtifacIdUtils.toVersionlessId(artifact));
}
use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.
the class DefaultArtifactTest method testPropertiesCopied.
@Test
public void testPropertiesCopied() {
Map<String, String> props = new HashMap<String, String>();
props.put("key", "value1");
Artifact a = new DefaultArtifact("gid:aid:1", props);
assertEquals("value1", a.getProperty("key", null));
props.clear();
assertEquals("value1", a.getProperty("key", null));
props.put("key", "value2");
a = a.setProperties(props);
assertEquals("value2", a.getProperty("key", null));
props.clear();
assertEquals("value2", a.getProperty("key", null));
}
Aggregations