use of org.sonatype.aether.graph.DependencyFilter in project zeppelin by apache.
the class DependencyContext method fetchArtifactWithDep.
private List<ArtifactResult> fetchArtifactWithDep(Dependency dep) throws DependencyResolutionException, ArtifactResolutionException {
Artifact artifact = new DefaultArtifact(dep.getGroupArtifactVersion());
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(dep.getExclusions());
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new org.sonatype.aether.graph.Dependency(artifact, JavaScopes.COMPILE));
collectRequest.addRepository(mavenCentral);
collectRequest.addRepository(mavenLocal);
for (Repository repo : repositories) {
RemoteRepository rr = new RemoteRepository(repo.getId(), "default", repo.getUrl());
rr.setPolicy(repo.isSnapshot(), null);
collectRequest.addRepository(rr);
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
use of org.sonatype.aether.graph.DependencyFilter 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.DependencyFilter in project sonatype-aether by sonatype.
the class PathRecordingDependencyVisitorTest method testFilterCalledWithProperParentStack.
@Test
public void testFilterCalledWithProperParentStack() throws Exception {
DependencyNode root = parse("parents.txt");
final StringBuilder buffer = new StringBuilder(256);
DependencyFilter filter = new DependencyFilter() {
public boolean accept(DependencyNode node, List<DependencyNode> parents) {
for (DependencyNode parent : parents) {
buffer.append(parent.getDependency().getArtifact().getArtifactId());
}
buffer.append(",");
return false;
}
};
PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor(filter);
root.accept(visitor);
assertEquals(",a,ba,cba,a,ea,", buffer.toString());
}
use of org.sonatype.aether.graph.DependencyFilter in project sonatype-aether by sonatype.
the class DependencyFilterUtilsTest method testClasspathFilterCompile.
@Test
public void testClasspathFilterCompile() {
NodeBuilder builder = new NodeBuilder().artifactId("aid");
DependencyFilter filter = DependencyFilterUtils.classpathFilter("compile");
assertTrue(filter.accept(builder.scope("compile").build(), PARENTS));
assertTrue(filter.accept(builder.scope("system").build(), PARENTS));
assertTrue(filter.accept(builder.scope("provided").build(), PARENTS));
assertFalse(filter.accept(builder.scope("runtime").build(), PARENTS));
assertFalse(filter.accept(builder.scope("test").build(), PARENTS));
}
use of org.sonatype.aether.graph.DependencyFilter in project sonatype-aether by sonatype.
the class DependencyFilterUtilsTest method testClasspathFilterRuntimeCommaSystem.
@Test
public void testClasspathFilterRuntimeCommaSystem() {
NodeBuilder builder = new NodeBuilder().artifactId("aid");
DependencyFilter filter = DependencyFilterUtils.classpathFilter("runtime,system");
assertTrue(filter.accept(builder.scope("compile").build(), PARENTS));
assertTrue(filter.accept(builder.scope("system").build(), PARENTS));
assertFalse(filter.accept(builder.scope("provided").build(), PARENTS));
assertTrue(filter.accept(builder.scope("runtime").build(), PARENTS));
assertFalse(filter.accept(builder.scope("test").build(), PARENTS));
}
Aggregations