use of org.eclipse.aether.graph.DependencyNode in project sts4 by spring-projects.
the class MavenCore method resolveDependencies.
/**
* Calculates dependency graph for a Maven project provided the scope.
*
* @param project Maven Project descriptor
* @param scope Dependency scope
* @return Set of all dependencies including transient ones
* @throws MavenException
*/
public Set<Artifact> resolveDependencies(MavenProject project, String scope) throws MavenException {
MavenExecutionRequest request = maven.createExecutionRequest();
DefaultRepositorySystemSession session = maven.createRepositorySession(request);
DependencyNode graph = readDependencyTree(maven.lookupComponent(org.eclipse.aether.RepositorySystem.class), session, project, scope);
if (graph != null) {
ArrayList<DependencyNode> dependencyNodes = new ArrayList<>();
graph.accept(new DependencyVisitor() {
public boolean visitEnter(DependencyNode node) {
if (node.getDependency() != null) {
dependencyNodes.add(node);
}
return true;
}
public boolean visitLeave(DependencyNode dependencynode) {
return true;
}
});
LinkedHashSet<Artifact> artifacts = new LinkedHashSet<>();
RepositoryUtils.toArtifacts(artifacts, dependencyNodes, Collections.singletonList(project.getArtifact().getId()), null);
return artifacts.parallelStream().map(artifact -> {
if (!artifact.isResolved()) {
try {
artifact = maven.resolve(artifact, project.getRemoteArtifactRepositories(), request);
} catch (MavenException e) {
Log.log(e);
// Maven 2.x quirk: an artifact always points at the local repo,
// regardless whether resolved or not
LocalRepositoryManager lrm = session.getLocalRepositoryManager();
String path = lrm.getPathForLocalArtifact(RepositoryUtils.toArtifact(artifact));
artifact.setFile(new File(lrm.getRepository().getBasedir(), path));
}
}
return artifact;
}).collect(Collectors.toSet());
}
return Collections.emptySet();
}
use of org.eclipse.aether.graph.DependencyNode in project druid by druid-io.
the class PullDependenciesTest method getArtifactsForExtension.
private List<Artifact> getArtifactsForExtension(Artifact artifact, DependencyFilter filter) {
final List<String> names = extensionToDependency.get(artifact);
final List<Artifact> artifacts = new ArrayList<>();
for (String name : names) {
final File jarFile = new File(localRepo, name + ".jar");
try {
jarFile.createNewFile();
} catch (IOException e) {
throw new RuntimeException(e);
}
DependencyNode node = new DefaultDependencyNode(new Dependency(new DefaultArtifact(DEPENDENCY_GROUPID, name, null, "jar", "1.0", null, jarFile), "compile"));
if (filter.accept(node, Collections.emptyList())) {
artifacts.add(node.getArtifact());
}
}
return artifacts;
}
use of org.eclipse.aether.graph.DependencyNode in project jqa-core-framework by buschmais.
the class AetherPluginResolverImpl method logDependencyTree.
private void logDependencyTree(DependencyNode node, int indent) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < indent; i++) {
builder.append(' ');
}
Artifact artifact = node.getArtifact();
if (artifact != null) {
log.info("{}{}", builder, artifact);
}
for (DependencyNode child : node.getChildren()) {
logDependencyTree(child, indent + 2);
}
}
Aggregations