use of org.sonatype.aether.graph.Dependency 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.graph.Dependency 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.graph.Dependency in project sonatype-aether by sonatype.
the class EdgeStack method find.
public GraphEdge find(Artifact artifact) {
for (int i = size - 1; i >= 0; i--) {
GraphEdge edge = edges[i];
Dependency dependency = edge.getDependency();
if (dependency == null) {
break;
}
Artifact a = dependency.getArtifact();
if (!a.getArtifactId().equals(artifact.getArtifactId())) {
continue;
}
if (!a.getGroupId().equals(artifact.getGroupId())) {
continue;
}
if (!a.getBaseVersion().equals(artifact.getBaseVersion())) {
continue;
}
if (!a.getExtension().equals(artifact.getExtension())) {
continue;
}
if (!a.getClassifier().equals(artifact.getClassifier())) {
continue;
}
return edge;
}
return null;
}
use of org.sonatype.aether.graph.Dependency in project sonatype-aether by sonatype.
the class GetDependencyTreeWithMirror method main.
public static void main(String[] args) throws Exception {
System.out.println("------------------------------------------------------------");
System.out.println(GetDependencyTreeWithMirror.class.getSimpleName());
RepositorySystem system = Booter.newRepositorySystem();
RepositorySystemSession session = Booter.newRepositorySystemSession(system);
Artifact artifact = new DefaultArtifact("org.apache.maven:maven-aether-provider:3.0.2");
RemoteRepository central = new RemoteRepository("central", "default", "http://repo1.maven.org/maven2/");
DefaultMirrorSelector dms = (DefaultMirrorSelector) session.getMirrorSelector();
dms.add("mirror", "http://repo1.maven.org/maven2/", "default", true, "central", "*");
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, ""));
collectRequest.addRepository(central);
CollectResult collectResult = system.collectDependencies(session, collectRequest);
collectResult.getRoot().accept(new ConsoleDependencyGraphDumper());
}
use of org.sonatype.aether.graph.Dependency in project sonatype-aether by sonatype.
the class GetDirectDependencies method main.
public static void main(String[] args) throws Exception {
System.out.println("------------------------------------------------------------");
System.out.println(GetDirectDependencies.class.getSimpleName());
RepositorySystem system = Booter.newRepositorySystem();
RepositorySystemSession session = Booter.newRepositorySystemSession(system);
Artifact artifact = new DefaultArtifact("org.sonatype.aether:aether-impl:1.9");
RemoteRepository repo = Booter.newCentralRepository();
ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
descriptorRequest.setArtifact(artifact);
descriptorRequest.addRepository(repo);
ArtifactDescriptorResult descriptorResult = system.readArtifactDescriptor(session, descriptorRequest);
for (Dependency dependency : descriptorResult.getDependencies()) {
System.out.println(dependency);
}
}
Aggregations