use of org.eclipse.aether.graph.DependencyNode in project maven-resolver by apache.
the class NearestVersionSelectorTest method testSelectHighestVersionFromMultipleVersionsAtSameLevel.
@Test
public void testSelectHighestVersionFromMultipleVersionsAtSameLevel() throws Exception {
DependencyNode root = parseResource("sibling-versions.txt");
assertSame(root, transform(root));
assertEquals(1, root.getChildren().size());
assertEquals("3", root.getChildren().get(0).getArtifact().getVersion());
}
use of org.eclipse.aether.graph.DependencyNode in project maven-resolver by apache.
the class CloningDependencyVisitor method visitEnter.
public final boolean visitEnter(DependencyNode node) {
boolean recurse = true;
DependencyNode clone = clones.get(node);
if (clone == null) {
clone = clone(node);
clones.put(node, clone);
} else {
recurse = false;
}
DependencyNode parent = parents.peek();
if (parent == null) {
root = clone;
} else {
parent.getChildren().add(clone);
}
parents.push(clone);
return recurse;
}
use of org.eclipse.aether.graph.DependencyNode in project maven-resolver by apache.
the class DefaultDependencyCollector method doRecurse.
@SuppressWarnings("checkstyle:parameternumber")
private void doRecurse(Args args, DependencyProcessingContext parentContext, ArtifactDescriptorResult descriptorResult, DefaultDependencyNode child) {
DefaultDependencyCollectionContext context = args.collectionContext;
context.set(parentContext.dependency, descriptorResult.getManagedDependencies());
DependencySelector childSelector = parentContext.depSelector != null ? parentContext.depSelector.deriveChildSelector(context) : null;
DependencyManager childManager = parentContext.depManager != null ? parentContext.depManager.deriveChildManager(context) : null;
DependencyTraverser childTraverser = parentContext.depTraverser != null ? parentContext.depTraverser.deriveChildTraverser(context) : null;
VersionFilter childFilter = parentContext.verFilter != null ? parentContext.verFilter.deriveChildFilter(context) : null;
final List<RemoteRepository> childRepos = args.ignoreRepos ? parentContext.repositories : remoteRepositoryManager.aggregateRepositories(args.session, parentContext.repositories, descriptorResult.getRepositories(), true);
Object key = args.pool.toKey(parentContext.dependency.getArtifact(), childRepos, childSelector, childManager, childTraverser, childFilter);
List<DependencyNode> children = args.pool.getChildren(key);
if (children == null) {
args.pool.putChildren(key, child.getChildren());
List<DependencyNode> parents = new ArrayList<>(parentContext.parents);
parents.add(child);
for (Dependency dependency : descriptorResult.getDependencies()) {
args.dependencyProcessingQueue.add(new DependencyProcessingContext(childSelector, childManager, childTraverser, childFilter, childRepos, descriptorResult.getManagedDependencies(), parents, dependency));
}
} else {
child.setChildren(children);
}
}
use of org.eclipse.aether.graph.DependencyNode in project maven-resolver by apache.
the class DefaultDependencyCycle method find.
/**
* Searches for a node associated with the given artifact. A version of the artifact is not considered during the
* search.
*
* @param nodes a list representing single path in the dependency graph. First element is the root.
* @param artifact to find among the parent nodes.
* @return the index of the node furthest from the root and associated with the given artifact, or {@literal -1} if
* there is no such node.
*/
public static int find(List<DependencyNode> nodes, Artifact artifact) {
for (int i = nodes.size() - 1; i >= 0; i--) {
DependencyNode node = nodes.get(i);
Artifact a = node.getArtifact();
if (a == null) {
break;
}
if (!a.getArtifactId().equals(artifact.getArtifactId())) {
continue;
}
if (!a.getGroupId().equals(artifact.getGroupId())) {
continue;
}
if (!a.getExtension().equals(artifact.getExtension())) {
continue;
}
if (!a.getClassifier().equals(artifact.getClassifier())) {
continue;
}
return i;
}
return -1;
}
use of org.eclipse.aether.graph.DependencyNode in project kie-soup by kiegroup.
the class MavenRepository method getArtifactDependecies.
public List<DependencyDescriptor> getArtifactDependecies(String artifactName) {
Artifact artifact = new DefaultArtifact(artifactName);
CollectRequest collectRequest = new CollectRequest();
Dependency root = new Dependency(artifact, "");
collectRequest.setRoot(root);
for (RemoteRepository repo : remoteRepositoriesForRequest) {
collectRequest.addRepository(repo);
}
CollectResult collectResult;
try {
collectResult = aether.getSystem().collectDependencies(aether.getSession(), collectRequest);
} catch (DependencyCollectionException e) {
throw new RuntimeException(e);
}
CollectDependencyVisitor visitor = new CollectDependencyVisitor();
collectResult.getRoot().accept(visitor);
List<DependencyDescriptor> descriptors = new ArrayList<DependencyDescriptor>();
for (DependencyNode node : visitor.getDependencies()) {
// skip root to not add artifact as dependency
if (node.getDependency().equals(root)) {
continue;
}
descriptors.add(new DependencyDescriptor(node.getDependency().getArtifact()));
}
return descriptors;
}
Aggregations