use of org.sonatype.aether.collection.CollectRequest in project storm by apache.
the class DependencyResolver method resolve.
public List<ArtifactResult> resolve(List<Dependency> dependencies) throws MalformedURLException, DependencyResolutionException, ArtifactResolutionException {
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE, JavaScopes.RUNTIME);
if (dependencies.size() == 0) {
return Collections.EMPTY_LIST;
}
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(dependencies.get(0));
for (int idx = 1; idx < dependencies.size(); idx++) {
collectRequest.addDependency(dependencies.get(idx));
}
for (RemoteRepository repository : remoteRepositories) {
collectRequest.addRepository(repository);
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFilter);
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
use of org.sonatype.aether.collection.CollectRequest in project zeppelin by apache.
the class SparkDependencyContext method fetchArtifactWithDep.
private List<ArtifactResult> fetchArtifactWithDep(Dependency dep) throws DependencyResolutionException, ArtifactResolutionException {
Artifact artifact = new DefaultArtifact(SparkDependencyResolver.inferScalaVersion(dep.getGroupArtifactVersion()));
DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(SparkDependencyResolver.inferScalaVersion(dep.getExclusions()));
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new org.sonatype.aether.graph.Dependency(artifact, JavaScopes.COMPILE));
collectRequest.addRepository(mavenCentral);
collectRequest.addRepository(mavenLocal);
for (RemoteRepository repo : additionalRepos) {
collectRequest.addRepository(repo);
}
for (Repository repo : repositories) {
RemoteRepository rr = new RemoteRepository(repo.getId(), "default", repo.getUrl());
rr.setPolicy(repo.isSnapshot(), null);
Authentication auth = repo.getAuthentication();
if (auth != null) {
rr.setAuthentication(auth);
}
collectRequest.addRepository(rr);
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.andFilter(exclusionFilter, classpathFlter));
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
use of org.sonatype.aether.collection.CollectRequest in project sonatype-aether by sonatype.
the class GetDependencyTree method main.
public static void main(String[] args) throws Exception {
System.out.println("------------------------------------------------------------");
System.out.println(GetDependencyTree.class.getSimpleName());
RepositorySystem system = Booter.newRepositorySystem();
RepositorySystemSession session = Booter.newRepositorySystemSession(system);
Artifact artifact = new DefaultArtifact("org.apache.maven:maven-aether-provider:3.0.2");
RemoteRepository repo = Booter.newCentralRepository();
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, ""));
collectRequest.addRepository(repo);
CollectResult collectResult = system.collectDependencies(session, collectRequest);
collectResult.getRoot().accept(new ConsoleDependencyGraphDumper());
}
use of org.sonatype.aether.collection.CollectRequest in project sonatype-aether by sonatype.
the class DefaultDependencyCollectorTest method testMissingDependencyDescription.
@Test
public void testMissingDependencyDescription() throws IOException {
DependencyNode root = parser.parseLiteral("missing:description:ext:ver");
CollectRequest request = new CollectRequest(root.getDependency(), Arrays.asList(repository));
try {
collector.collectDependencies(session, request);
fail("expected exception");
} catch (DependencyCollectionException e) {
CollectResult result = e.getResult();
assertSame(request, result.getRequest());
assertNotNull(result.getExceptions());
assertEquals(1, result.getExceptions().size());
assertTrue(result.getExceptions().get(0) instanceof ArtifactDescriptorException);
assertEquals(request.getRoot(), result.getRoot().getDependency());
}
}
use of org.sonatype.aether.collection.CollectRequest in project sonatype-aether by sonatype.
the class DefaultDependencyCollectorTest method testPartialResultOnError.
@Test
public void testPartialResultOnError() throws IOException {
DependencyNode root = parser.parse("expectedPartialSubtreeOnError.txt");
Dependency dependency = root.getDependency();
CollectRequest request = new CollectRequest(dependency, Arrays.asList(repository));
CollectResult result;
try {
result = collector.collectDependencies(session, request);
fail("expected exception ");
} catch (DependencyCollectionException e) {
result = e.getResult();
assertSame(request, result.getRequest());
assertNotNull(result.getExceptions());
assertEquals(1, result.getExceptions().size());
assertTrue(result.getExceptions().get(0) instanceof ArtifactDescriptorException);
assertEqualSubtree(root, result.getRoot());
}
}
Aggregations