use of org.eclipse.aether.resolution.DependencyResult 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.DependencyResult in project jqa-core-framework by buschmais.
the class AetherPluginResolverImpl method resolvePlugins.
private DependencyResult resolvePlugins(List<Dependency> dependencies) {
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(RUNTIME);
DependencyResult dependencyResult = resolveDependencies(classpathFilter, dependencies);
if (log.isDebugEnabled()) {
logDependencyTree(dependencyResult.getRoot(), 0);
}
return dependencyResult;
}
use of org.eclipse.aether.resolution.DependencyResult in project intellij-community by JetBrains.
the class ArtifactRepositoryManager method resolveDependency.
public Collection<File> resolveDependency(String groupId, String artifactId, String version) throws Exception {
final DependencyRequest dependencyRequest = new DependencyRequest(createCollectRequest(groupId, artifactId, toVersion(version)), DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE));
final DependencyResult result = ourSystem.resolveDependencies(mySession, dependencyRequest);
final List<File> files = new ArrayList<>();
for (ArtifactResult artifactResult : result.getArtifactResults()) {
files.add(artifactResult.getArtifact().getFile());
}
return files;
}
use of org.eclipse.aether.resolution.DependencyResult in project spf4j by zolyfarkas.
the class MavenRepositoryUtils method resolveArtifactAndDependencies.
public static Set<File> resolveArtifactAndDependencies(final String scope, final String groupId, final String artifactId, final String classifier, final String extension, final String versionExpr, final List<RemoteRepository> repos, final RepositorySystem repositorySystem, final RepositorySystemSession session) throws DependencyResolutionException {
Artifact artifact = new DefaultArtifact(groupId, artifactId, classifier, extension, versionExpr);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, scope));
collectRequest.setRepositories(repos);
DependencyFilter dependencyFilter = DependencyFilterUtils.classpathFilter(scope);
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, dependencyFilter);
DependencyResult depresult = repositorySystem.resolveDependencies(session, dependencyRequest);
List<ArtifactResult> artifactResults = depresult.getArtifactResults();
Set<File> result = Sets.newHashSetWithExpectedSize(artifactResults.size());
for (ArtifactResult ar : artifactResults) {
result.add(ar.getArtifact().getFile());
}
return result;
}
use of org.eclipse.aether.resolution.DependencyResult in project gate-core by GateNLP.
the class SimpleMavenCache method cacheArtifact.
public void cacheArtifact(Artifact artifact) throws IOException, SettingsBuildingException, DependencyCollectionException, DependencyResolutionException, ArtifactResolutionException, ModelBuildingException {
List<RemoteRepository> repos = getRepositoryList();
Dependency dependency = new Dependency(artifact, "runtime");
RepositorySystem repoSystem = getRepositorySystem();
RepositorySystemSession repoSession = getRepositorySession(repoSystem, null);
CollectRequest collectRequest = new CollectRequest(dependency, repos);
DependencyNode node = repoSystem.collectDependencies(repoSession, collectRequest).getRoot();
DependencyRequest dependencyRequest = new DependencyRequest();
dependencyRequest.setRoot(node);
DependencyResult result = repoSystem.resolveDependencies(repoSession, dependencyRequest);
for (ArtifactResult ar : result.getArtifactResults()) {
// generate output file name from the *requested* artifact rather
// than the resolved one (e.g. if we requested a -SNAPSHOT version
// but got a timestamped one)
File file = getArtifactFile(ar.getRequest().getArtifact());
FileUtils.copyFile(ar.getArtifact().getFile(), file);
// get the POM corresponding to the specific resolved JAR
Artifact pomArtifact = new SubArtifact(ar.getArtifact(), "", "pom");
ArtifactRequest artifactRequest = new ArtifactRequest(pomArtifact, repos, null);
ArtifactResult artifactResult = repoSystem.resolveArtifact(repoSession, artifactRequest);
// but copy it to a file named for the original requested version number
file = getArtifactFile(new SubArtifact(ar.getRequest().getArtifact(), "", "pom"));
FileUtils.copyFile(artifactResult.getArtifact().getFile(), file);
cacheParents(artifactResult.getArtifact().getFile(), repoSystem, repoSession, repos);
}
}
Aggregations