use of org.eclipse.aether.resolution.DependencyResult in project buck by facebook.
the class Resolver method getRunTimeTransitiveDeps.
private ImmutableMap<String, Artifact> getRunTimeTransitiveDeps(Iterable<Dependency> mavenCoords) throws RepositoryException {
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRequestContext(JavaScopes.RUNTIME);
collectRequest.setRepositories(repos);
for (Dependency dep : mavenCoords) {
collectRequest.addDependency(dep);
}
DependencyFilter filter = DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME);
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, filter);
DependencyResult dependencyResult = repoSys.resolveDependencies(session, dependencyRequest);
ImmutableSortedMap.Builder<String, Artifact> knownDeps = ImmutableSortedMap.naturalOrder();
for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) {
Artifact node = artifactResult.getArtifact();
knownDeps.put(buildKey(node), node);
}
return knownDeps.build();
}
use of org.eclipse.aether.resolution.DependencyResult in project spring-boot by spring-projects.
the class AetherGrapeEngine method resolve.
private List<File> resolve(List<Dependency> dependencies) throws ArtifactResolutionException {
try {
CollectRequest collectRequest = getCollectRequest(dependencies);
DependencyRequest dependencyRequest = getDependencyRequest(collectRequest);
DependencyResult result = this.repositorySystem.resolveDependencies(this.session, dependencyRequest);
addManagedDependencies(result);
return getFiles(result);
} catch (Exception ex) {
throw new DependencyResolutionFailedException(ex);
} finally {
this.progressReporter.finished();
}
}
use of org.eclipse.aether.resolution.DependencyResult in project spring-boot by spring-projects.
the class ModifiedClassPathRunner method resolveCoordinates.
private List<URL> resolveCoordinates(String[] coordinates) throws Exception {
DefaultServiceLocator serviceLocator = MavenRepositorySystemUtils.newServiceLocator();
serviceLocator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
serviceLocator.addService(TransporterFactory.class, HttpTransporterFactory.class);
RepositorySystem repositorySystem = serviceLocator.getService(RepositorySystem.class);
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
LocalRepository localRepository = new LocalRepository(System.getProperty("user.home") + "/.m2/repository");
session.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(session, localRepository));
CollectRequest collectRequest = new CollectRequest(null, Arrays.asList(new RemoteRepository.Builder("central", "default", "http://central.maven.org/maven2").build()));
collectRequest.setDependencies(createDependencies(coordinates));
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null);
DependencyResult result = repositorySystem.resolveDependencies(session, dependencyRequest);
List<URL> resolvedArtifacts = new ArrayList<URL>();
for (ArtifactResult artifact : result.getArtifactResults()) {
resolvedArtifacts.add(artifact.getArtifact().getFile().toURI().toURL());
}
return resolvedArtifacts;
}
use of org.eclipse.aether.resolution.DependencyResult in project byte-buddy by raphw.
the class ClassLoaderResolverTest method testResolutionFailure.
@Test(expected = MojoExecutionException.class)
public void testResolutionFailure() throws Exception {
when(repositorySystem.resolveDependencies(eq(repositorySystemSession), any(DependencyRequest.class))).thenThrow(new DependencyResolutionException(new DependencyResult(new DependencyRequest(root, mock(DependencyFilter.class))), new Throwable()));
classLoaderResolver.resolve(new MavenCoordinate(FOO, BAR, QUX));
}
use of org.eclipse.aether.resolution.DependencyResult in project atlasmap by atlasmap.
the class GenerateInspectionsMojo method resolveClasspath.
private List<URL> resolveClasspath(List<String> artifacts) throws MojoFailureException {
final List<URL> urls = new ArrayList<>();
try {
for (String gav : artifacts) {
Artifact artifact = new DefaultArtifact(gav);
getLog().debug("Resolving dependencies for artifact: " + artifact);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, ""));
collectRequest.setRepositories(remoteRepos);
DependencyRequest dependencyRequest = new DependencyRequest();
dependencyRequest.setCollectRequest(collectRequest);
DependencyResult dependencyResult = system.resolveDependencies(repoSession, dependencyRequest);
PreorderNodeListGenerator nlg = new PreorderNodeListGenerator();
dependencyResult.getRoot().accept(nlg);
Iterator<DependencyNode> it = nlg.getNodes().iterator();
while (it.hasNext()) {
DependencyNode node = it.next();
if (node.getDependency() != null) {
Artifact x = node.getDependency().getArtifact();
if (x.getFile() != null) {
getLog().debug("Found dependency: " + x + " for artifact: " + artifact);
urls.add(x.getFile().toURI().toURL());
}
}
}
}
} catch (IllegalArgumentException e) {
throw new MojoFailureException(e.getMessage(), e);
} catch (DependencyResolutionException e) {
throw new MojoFailureException(e.getMessage(), e);
} catch (MalformedURLException e) {
throw new MojoFailureException(e.getMessage(), e);
}
return urls;
}
Aggregations