use of org.sonatype.aether.graph.Dependency in project zeppelin by apache.
the class SparkDependencyResolver method getArtifactsWithDep.
/**
* @param dependency
* @param excludes list of pattern can either be of the form groupId:artifactId
* @return
* @throws Exception
*/
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency, Collection<String> excludes) throws Exception {
Artifact artifact = new DefaultArtifact(inferScalaVersion(dependency));
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(inferScalaVersion(excludes));
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
synchronized (repos) {
for (RemoteRepository repo : repos) {
collectRequest.addRepository(repo);
}
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
use of org.sonatype.aether.graph.Dependency in project sonatype-aether by sonatype.
the class DependencyTest method testSetExclusions.
@Test
public void testSetExclusions() {
Dependency d1 = new Dependency(new StubArtifact("gid:aid:ver"), "compile", false, Collections.singleton(new Exclusion("g", "a", "c", "e")));
Dependency d2 = d1.setExclusions(null);
assertNotSame(d2, d1);
assertEquals(0, d2.getExclusions().size());
assertSame(d2, d2.setExclusions(null));
assertSame(d2, d2.setExclusions(Collections.<Exclusion>emptyList()));
assertSame(d2, d2.setExclusions(Collections.<Exclusion>emptySet()));
assertSame(d1, d1.setExclusions(Arrays.asList(new Exclusion("g", "a", "c", "e"))));
Dependency d3 = d1.setExclusions(Arrays.asList(new Exclusion("g", "a", "c", "e"), new Exclusion("g", "a", "c", "f")));
assertNotSame(d3, d1);
assertEquals(2, d3.getExclusions().size());
}
use of org.sonatype.aether.graph.Dependency in project sonatype-aether by sonatype.
the class DependencyTest method testSetScope.
@Test
public void testSetScope() {
Dependency d1 = new Dependency(new StubArtifact("gid:aid:ver"), "compile");
Dependency d2 = d1.setScope(null);
assertNotSame(d2, d1);
assertEquals("", d2.getScope());
Dependency d3 = d1.setScope("test");
assertNotSame(d3, d1);
assertEquals("test", d3.getScope());
}
use of org.sonatype.aether.graph.Dependency in project sonatype-aether by sonatype.
the class DefaultDependencyCollectorTest method testDuplicates.
@Test
public void testDuplicates() throws IOException, DependencyCollectionException {
DependencyNode root = parser.parseLiteral("duplicate:transitive:ext:dependency");
Dependency dependency = root.getDependency();
CollectRequest request = new CollectRequest(dependency, Arrays.asList(repository));
CollectResult result = collector.collectDependencies(session, request);
assertEquals(0, result.getExceptions().size());
DependencyNode newRoot = result.getRoot();
Dependency newDependency = newRoot.getDependency();
assertEquals(dependency, newDependency);
assertEquals(dependency.getArtifact(), newDependency.getArtifact());
assertEquals(2, newRoot.getChildren().size());
DependencyNode expect = parser.parseLiteral("gid:aid:ext:ver:compile");
Dependency dep = expect.getDependency();
assertEquals(dep, dep(newRoot, 0));
expect = parser.parseLiteral("gid:aid2:ext:ver:compile");
dep = expect.getDependency();
assertEquals(dep, dep(newRoot, 1));
assertEquals(dep, dep(newRoot, 0, 0));
assertEquals(dep(newRoot, 1), dep(newRoot, 0, 0));
}
use of org.sonatype.aether.graph.Dependency in project sonatype-aether by sonatype.
the class DefaultDependencyCollectorTest method testEqualSubtree.
@Test
public void testEqualSubtree() throws IOException, DependencyCollectionException {
DependencyNode root = parser.parse("expectedSubtreeComparisonResult.txt");
Dependency dependency = root.getDependency();
CollectRequest request = new CollectRequest(dependency, Arrays.asList(repository));
CollectResult result = collector.collectDependencies(session, request);
assertEqualSubtree(root, result.getRoot());
}
Aggregations