use of org.eclipse.aether.graph.DependencyFilter 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.graph.DependencyFilter in project bnd by bndtools.
the class DependencyResolver method resolve.
public Map<File, ArtifactResult> resolve() throws MojoExecutionException {
if (resolvedDependencies != null) {
return resolvedDependencies;
}
DependencyResolutionRequest request = new DefaultDependencyResolutionRequest(project, session);
request.setResolutionFilter(new DependencyFilter() {
@Override
public boolean accept(DependencyNode node, List<DependencyNode> parents) {
if (node.getDependency() != null) {
return scopes.contains(node.getDependency().getScope());
}
return false;
}
});
DependencyResolutionResult result;
try {
result = resolver.resolve(request);
} catch (DependencyResolutionException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
Map<File, ArtifactResult> dependencies = new HashMap<>();
DependencyNode dependencyGraph = result.getDependencyGraph();
if (dependencyGraph != null && !dependencyGraph.getChildren().isEmpty()) {
List<RemoteRepository> remoteRepositories = new ArrayList<>(project.getRemoteProjectRepositories());
ArtifactRepository deployRepo = project.getDistributionManagementArtifactRepository();
if (deployRepo != null) {
remoteRepositories.add(RepositoryUtils.toRepo(deployRepo));
}
discoverArtifacts(dependencies, dependencyGraph.getChildren(), project.getArtifact().getId(), remoteRepositories);
}
return resolvedDependencies = dependencies;
}
use of org.eclipse.aether.graph.DependencyFilter 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;
}
use of org.eclipse.aether.graph.DependencyFilter in project fabric8 by jboss-fuse.
the class AetherBasedResolver method resolveDependencies.
protected DependencyNode resolveDependencies(RepositorySystemSession session, List<RemoteRepository> repos, DependencyNode pomNode, Dependency dependency, final Filter<Dependency> shouldExclude) throws FailedToResolveDependency {
if (!DependencyFilters.matches(dependency, shouldExclude)) {
CollectRequest cr = new CollectRequest(dependency, repos);
// request.setRequestContext("runtime");
try {
DependencyNode node = m_repoSystem.collectDependencies(session, cr).getRoot();
DependencyFilter filter = new DependencyFilter() {
public boolean accept(DependencyNode node, List<DependencyNode> parents) {
return !DependencyFilters.matches(node, shouldExclude);
}
};
DependencyRequest request = new DependencyRequest(cr, filter);
m_repoSystem.resolveDependencies(session, request);
return node;
} catch (DependencyResolutionException | DependencyCollectionException e) {
handleDependencyResolveFailure(pomNode, dependency, e);
}
}
return null;
}
use of org.eclipse.aether.graph.DependencyFilter 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;
}
Aggregations