use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class DefaultDependencyCollectorTest method testCyclicDependenciesBig.
@Test
public void testCyclicDependenciesBig() throws Exception {
DependencyNode root = parser.parse("cycle-big.txt");
CollectRequest request = new CollectRequest(root.getDependency(), Arrays.asList(repository));
collector.setArtifactDescriptorReader(new IniArtifactDescriptorReader("artifact-descriptions/cycle-big/"));
CollectResult result = collector.collectDependencies(session, request);
assertNotNull(result.getRoot());
// we only care about the performance here, this test must not hang or run out of mem
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class PathRecordingDependencyVisitor method visitEnter.
public boolean visitEnter(DependencyNode node) {
boolean accept = filter == null || filter.accept(node, parents);
parents.push(node);
if (accept) {
DependencyNode[] path = new DependencyNode[parents.size()];
int i = parents.size() - 1;
for (DependencyNode n : parents) {
path[i] = n;
i--;
}
paths.add(Arrays.asList(path));
}
return !(excludeChildrenOfMatches && accept);
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class ConflictIdSorter method buildConflitIdDAG.
private void buildConflitIdDAG(Map<Object, ConflictId> ids, DependencyNode node, ConflictId id, int depth, Map<DependencyNode, Object> visited, Map<?, ?> conflictIds) {
if (visited.put(node, Boolean.TRUE) != null) {
return;
}
depth++;
for (DependencyNode child : node.getChildren()) {
Object key = conflictIds.get(child);
ConflictId childId = ids.get(key);
if (childId == null) {
childId = new ConflictId(key, depth);
ids.put(key, childId);
} else {
childId.pullup(depth);
}
if (id != null) {
id.add(childId);
}
buildConflitIdDAG(ids, child, childId, depth, visited, conflictIds);
}
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class ConflictMarker method analyze.
private void analyze(DependencyNode node, Map<DependencyNode, Object> nodes, Map<Object, ConflictGroup> groups) {
if (nodes.put(node, SEEN) != null) {
return;
}
Set<Object> keys = getKeys(node);
if (!keys.isEmpty()) {
ConflictGroup group = null;
boolean fixMappings = false;
for (Object key : keys) {
ConflictGroup g = groups.get(key);
if (group != g) {
if (group == null) {
Set<Object> newKeys = merge(g.keys, keys);
if (newKeys == g.keys) {
group = g;
break;
} else {
group = new ConflictGroup(newKeys);
fixMappings = true;
}
} else if (g == null) {
fixMappings = true;
} else {
Set<Object> newKeys = merge(g.keys, group.keys);
if (newKeys == g.keys) {
group = g;
fixMappings = false;
break;
} else if (newKeys != group.keys) {
group = new ConflictGroup(newKeys);
fixMappings = true;
}
}
}
}
if (group == null) {
group = new ConflictGroup(keys);
fixMappings = true;
}
if (fixMappings) {
for (Object key : group.keys) {
groups.put(key, group);
}
}
}
for (DependencyNode child : node.getChildren()) {
analyze(child, nodes, groups);
}
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class JavaEffectiveScopeCalculator method transformGraph.
public DependencyNode transformGraph(DependencyNode node, DependencyGraphTransformationContext context) throws RepositoryException {
List<?> sortedConflictIds = (List<?>) context.get(TransformationContextKeys.SORTED_CONFLICT_IDS);
if (sortedConflictIds == null) {
ConflictIdSorter sorter = new ConflictIdSorter();
sorter.transformGraph(node, context);
sortedConflictIds = (List<?>) context.get(TransformationContextKeys.SORTED_CONFLICT_IDS);
}
Map<?, ?> conflictIds = (Map<?, ?>) context.get(TransformationContextKeys.CONFLICT_IDS);
if (conflictIds == null) {
throw new RepositoryException("conflict groups have not been identified");
}
Boolean cyclicConflictIds = (Boolean) context.get(TransformationContextKeys.CYCLIC_CONFLICT_IDS);
Map<Object, ConflictGroup> groups = new HashMap<Object, ConflictGroup>(256);
buildConflictGroups(groups, node, null, conflictIds);
String rootScope = "";
if (node.getDependency() != null) {
Object key = conflictIds.get(node);
groups.get(key).scope = rootScope = node.getDependency().getScope();
}
for (DependencyNode child : node.getChildren()) {
Object key = conflictIds.get(child);
groups.get(key).scope = getInheritedScope(rootScope, child.getDependency().getScope());
}
Set<Object> prequisites = null;
if (Boolean.TRUE.equals(cyclicConflictIds)) {
prequisites = new HashSet<Object>(sortedConflictIds.size() * 2);
}
for (Object key : sortedConflictIds) {
if (prequisites != null) {
prequisites.add(key);
}
ConflictGroup group = groups.get(key);
resolve(group, conflictIds, prequisites);
}
return node;
}
Aggregations