use of org.eclipse.aether.resolution.DependencyResolutionException in project revapi by revapi.
the class ArtifactResolver method collectTransitiveDeps.
protected void collectTransitiveDeps(String gav, Set<Artifact> resolvedArtifacts, Set<Exception> failures) throws RepositoryException {
final Artifact rootArtifact = resolveArtifact(gav);
CollectRequest collectRequest = new CollectRequest(new Dependency(rootArtifact, null), repositories);
DependencyRequest request = new DependencyRequest(collectRequest, null);
DependencyResult result;
try {
result = repositorySystem.resolveDependencies(session, request);
} catch (DependencyResolutionException dre) {
result = dre.getResult();
}
result.getRoot().accept(new TreeDependencyVisitor(new DependencyVisitor() {
@Override
public boolean visitEnter(DependencyNode node) {
return true;
}
@Override
public boolean visitLeave(DependencyNode node) {
Dependency dep = node.getDependency();
if (dep == null || dep.getArtifact().equals(rootArtifact)) {
return true;
}
resolvedArtifacts.add(dep.getArtifact());
return true;
}
}));
failures.addAll(result.getCollectExceptions());
}
use of org.eclipse.aether.resolution.DependencyResolutionException in project jqa-core-framework by buschmais.
the class AetherPluginResolverImpl method resolveDependencies.
private DependencyResult resolveDependencies(DependencyFilter classpathFilter, List<Dependency> dependencies) {
CollectRequest collectRequest = new CollectRequest();
collectRequest.setDependencies(dependencies);
collectRequest.setRepositories(repositories);
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFilter);
try {
return repositorySystem.resolveDependencies(repositorySystemSession, dependencyRequest);
} catch (DependencyResolutionException e) {
throw new PluginRepositoryException("Cannot resolve plugin dependencies", e);
}
}
use of org.eclipse.aether.resolution.DependencyResolutionException in project zeppelin by apache.
the class DependencyResolver 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 RepositoryException {
Artifact artifact = new DefaultArtifact(dependency);
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(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));
try {
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
} catch (NullPointerException | DependencyResolutionException ex) {
throw new RepositoryException(String.format("Cannot fetch dependencies for %s", dependency), ex);
}
}
use of org.eclipse.aether.resolution.DependencyResolutionException in project byte-buddy by raphw.
the class ClassLoaderResolver method doResolve.
/**
* Resolves a Maven coordinate to a class loader that can load all of the coordinates classes.
*
* @param mavenCoordinate The Maven coordinate to resolve.
* @return A class loader that references all of the class loader's dependencies and which is a child of this class's class loader.
* @throws MojoExecutionException If the user configuration results in an error.
* @throws MojoFailureException If the plugin application raises an error.
*/
private ClassLoader doResolve(MavenCoordinate mavenCoordinate) throws MojoExecutionException, MojoFailureException {
List<URL> urls = new ArrayList<URL>();
log.info("Resolving transformer dependency: " + mavenCoordinate);
try {
DependencyNode root = repositorySystem.collectDependencies(repositorySystemSession, new CollectRequest(new Dependency(mavenCoordinate.asArtifact(), "runtime"), remoteRepositories)).getRoot();
repositorySystem.resolveDependencies(repositorySystemSession, new DependencyRequest().setRoot(root));
PreorderNodeListGenerator preorderNodeListGenerator = new PreorderNodeListGenerator();
root.accept(preorderNodeListGenerator);
for (Artifact artifact : preorderNodeListGenerator.getArtifacts(false)) {
urls.add(artifact.getFile().toURI().toURL());
}
} catch (DependencyCollectionException exception) {
throw new MojoExecutionException("Could not collect dependencies for " + mavenCoordinate, exception);
} catch (DependencyResolutionException exception) {
throw new MojoExecutionException("Could not resolve dependencies for " + mavenCoordinate, exception);
} catch (MalformedURLException exception) {
throw new MojoFailureException("Could not resolve file as URL for " + mavenCoordinate, exception);
}
return new URLClassLoader(urls.toArray(new URL[urls.size()]), ByteBuddy.class.getClassLoader());
}
use of org.eclipse.aether.resolution.DependencyResolutionException in project qpid-broker-j by apache.
the class ClasspathQuery method getJarFiles.
private static Set<File> getJarFiles(final Collection<String> gavs) {
Set<File> jars = new HashSet<>();
for (final String gav : gavs) {
Artifact artifact = new DefaultArtifact(gav);
DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
collectRequest.setRepositories(Booter.newRepositories());
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFlter);
List<ArtifactResult> artifactResults = null;
try {
artifactResults = _mavenRepositorySystem.resolveDependencies(_mavenRepositorySession, dependencyRequest).getArtifactResults();
} catch (DependencyResolutionException e) {
throw new RuntimeException(String.format("Error while dependency resolution for '%s'", gav), e);
}
if (artifactResults == null) {
throw new RuntimeException(String.format("Could not resolve dependency for '%s'", gav));
}
for (ArtifactResult artifactResult : artifactResults) {
System.out.println(artifactResult.getArtifact() + " resolved to " + artifactResult.getArtifact().getFile());
}
jars.addAll(artifactResults.stream().map(result -> result.getArtifact().getFile()).collect(Collectors.toSet()));
}
return jars;
}
Aggregations