use of org.sonatype.aether.graph.Dependency in project sonatype-aether by sonatype.
the class ScopeDependencyFilter method accept.
public boolean accept(DependencyNode node, List<DependencyNode> parents) {
Dependency dependency = node.getDependency();
if (dependency == null) {
return true;
}
String scope = node.getDependency().getScope();
return (included.isEmpty() || included.contains(scope)) && (excluded.isEmpty() || !excluded.contains(scope));
}
use of org.sonatype.aether.graph.Dependency in project sonatype-aether by sonatype.
the class ClassicDependencyManager method deriveChildManager.
public DependencyManager deriveChildManager(DependencyCollectionContext context) {
if (depth >= 2) {
return this;
} else if (depth == 1) {
return new ClassicDependencyManager(depth + 1, managedVersions, managedScopes, managedLocalPaths, managedExclusions);
}
Map<Object, String> managedVersions = this.managedVersions;
Map<Object, String> managedScopes = this.managedScopes;
Map<Object, String> managedLocalPaths = this.managedLocalPaths;
Map<Object, Collection<Exclusion>> managedExclusions = this.managedExclusions;
for (Dependency managedDependency : context.getManagedDependencies()) {
Artifact artifact = managedDependency.getArtifact();
Object key = getKey(artifact);
String version = artifact.getVersion();
if (version.length() > 0 && !managedVersions.containsKey(key)) {
if (managedVersions == this.managedVersions) {
managedVersions = new HashMap<Object, String>(this.managedVersions);
}
managedVersions.put(key, version);
}
String scope = managedDependency.getScope();
if (scope.length() > 0 && !managedScopes.containsKey(key)) {
if (managedScopes == this.managedScopes) {
managedScopes = new HashMap<Object, String>(this.managedScopes);
}
managedScopes.put(key, scope);
}
String localPath = managedDependency.getArtifact().getProperty(ArtifactProperties.LOCAL_PATH, null);
if (localPath != null && !managedLocalPaths.containsKey(key)) {
if (managedLocalPaths == this.managedLocalPaths) {
managedLocalPaths = new HashMap<Object, String>(this.managedLocalPaths);
}
managedLocalPaths.put(key, localPath);
}
Collection<Exclusion> exclusions = managedDependency.getExclusions();
if (!exclusions.isEmpty()) {
if (managedExclusions == this.managedExclusions) {
managedExclusions = new HashMap<Object, Collection<Exclusion>>(this.managedExclusions);
}
Collection<Exclusion> managed = managedExclusions.get(key);
if (managed == null) {
managed = new LinkedHashSet<Exclusion>();
managedExclusions.put(key, managed);
}
managed.addAll(exclusions);
}
}
return new ClassicDependencyManager(depth + 1, managedVersions, managedScopes, managedLocalPaths, managedExclusions);
}
use of org.sonatype.aether.graph.Dependency in project sonatype-aether by sonatype.
the class ExclusionDependencySelector method deriveChildSelector.
public DependencySelector deriveChildSelector(DependencyCollectionContext context) {
Dependency dependency = context.getDependency();
Collection<Exclusion> exclusions = (dependency != null) ? dependency.getExclusions() : null;
if (exclusions == null || exclusions.isEmpty()) {
return this;
}
Set<Exclusion> merged = new LinkedHashSet<Exclusion>();
merged.addAll(this.exclusions);
merged.addAll(exclusions);
return new ExclusionDependencySelector(merged);
}
use of org.sonatype.aether.graph.Dependency in project sonatype-aether by sonatype.
the class DependencyGraphDumper method dump.
private static void dump(Context context, DependencyNode node, int depth, boolean last) {
Line line = context.nodes.get(node);
if (line != null) {
if (line.id <= 0) {
line.id = ++context.ids;
}
context.lines.add(new Line(null, line.id, depth, last));
return;
}
Dependency dependency = node.getDependency();
if (dependency == null) {
line = new Line(null, 0, depth, last);
} else {
line = new Line(dependency, 0, depth, last);
}
context.lines.add(line);
context.nodes.put(node, line);
depth++;
for (Iterator<DependencyNode> it = node.getChildren().iterator(); it.hasNext(); ) {
DependencyNode child = it.next();
dump(context, child, depth, !it.hasNext());
}
}
use of org.sonatype.aether.graph.Dependency in project sonatype-aether by sonatype.
the class DependencyGraphParserTest method testOptionalScope.
@Test
public void testOptionalScope() throws IOException {
String def = "gid:aid:jar:1";
DependencyNode node = parser.parseLiteral(def);
assertNotNull(node);
assertEquals(0, node.getChildren().size());
Dependency dependency = node.getDependency();
assertNotNull(dependency);
assertEquals("", dependency.getScope());
}
Aggregations