use of org.eclipse.aether.graph.DependencyNode in project activemq-artemis by rh-messaging.
the class ArtemisAbstractPlugin method explodeDependencies.
protected List<Artifact> explodeDependencies(Artifact artifact) throws DependencyCollectionException {
final List<Artifact> dependencies = new LinkedList<>();
CollectRequest exploreDependenciesRequest = new CollectRequest(new Dependency(artifact, "compile"), remoteRepos);
CollectResult result = repositorySystem.collectDependencies(repoSession, exploreDependenciesRequest);
final AtomicInteger level = new AtomicInteger(0);
DependencyNode node = result.getRoot();
StringWriter writer = new StringWriter();
final PrintWriter strPrint = new PrintWriter(writer);
strPrint.println("Dependencies explored for " + artifact + ":");
if (node != null) {
node.accept(new DependencyVisitor() {
@Override
public boolean visitEnter(DependencyNode node) {
for (int i = 0; i < level.get(); i++) {
strPrint.print("!...");
}
level.incrementAndGet();
strPrint.println("Dependency:: " + node.getDependency() + " node = " + node.getArtifact());
dependencies.add(node.getArtifact());
return true;
}
@Override
public boolean visitLeave(DependencyNode node) {
level.decrementAndGet();
return true;
}
});
}
getLog().info(writer.toString());
return dependencies;
}
use of org.eclipse.aether.graph.DependencyNode in project quarkus-platform by quarkusio.
the class QuarkusProjectStateMojoBase method ensureResolvable.
private Collection<Path> ensureResolvable(Artifact a) throws MojoExecutionException {
final DependencyNode root;
try {
root = artifactResolver().collectDependencies(a, Collections.emptyList()).getRoot();
} catch (Exception e) {
throw new MojoExecutionException("Failed to collect dependencies of " + a, e);
}
final List<Path> createdDirs = new ArrayList<>();
ensureResolvableModule(root, artifactResolver().getMavenContext().getWorkspace(), createdDirs);
return createdDirs;
}
use of org.eclipse.aether.graph.DependencyNode in project quarkus-platform by quarkusio.
the class GoOfflineMojo method ensureResolvableModule.
private static void ensureResolvableModule(DependencyNode node, LocalWorkspace workspace, List<Path> createdDirs) throws MojoExecutionException {
Artifact artifact = node.getArtifact();
if (artifact != null) {
final LocalProject module = workspace.getProject(artifact.getGroupId(), artifact.getArtifactId());
if (module != null && !module.getRawModel().getPackaging().equals(ArtifactCoords.TYPE_POM)) {
final Path classesDir = module.getClassesDir();
if (!Files.exists(classesDir)) {
Path topDirToCreate = classesDir;
while (!Files.exists(topDirToCreate.getParent())) {
topDirToCreate = topDirToCreate.getParent();
}
try {
Files.createDirectories(classesDir);
createdDirs.add(topDirToCreate);
} catch (IOException e) {
throw new MojoExecutionException("Failed to create " + classesDir, e);
}
}
}
}
for (DependencyNode c : node.getChildren()) {
ensureResolvableModule(c, workspace, createdDirs);
}
}
use of org.eclipse.aether.graph.DependencyNode in project bacon by project-ncl.
the class QuarkusCommunityDepAnalyzer method collectNonOptionalDependencies.
private void collectNonOptionalDependencies(DependencyNode depNode, Set<GAV> dependencies, Multimap<GAV, GAV> dependenciesBySource, GAV extension, HashSet<GAV> visitedNodes) {
GAV current = gavFromDepNode(depNode);
if (!visitedNodes.add(current)) {
return;
}
depNode.getChildren().stream().filter(d -> !d.getDependency().isOptional()).peek(d -> {
GAV gav = gavFromDepNode(d);
if (!gav.getVersion().contains("redhat")) {
dependenciesBySource.put(gav, extension);
dependencies.add(gav);
}
}).forEach(d -> collectNonOptionalDependencies(d, dependencies, dependenciesBySource, extension, visitedNodes));
}
use of org.eclipse.aether.graph.DependencyNode in project lsp4mp by eclipse.
the class DependencyUtil method getDependencies.
public static Set<org.eclipse.lsp4mp.jdt.core.ArtifactResolver.Artifact> getDependencies(String groupId, String artifactId, String version, IProgressMonitor monitor) throws CoreException {
org.eclipse.aether.artifact.Artifact artifact = new DefaultArtifact(groupId, artifactId, null, version);
CollectResult result = MavenPlugin.getMaven().execute((context, progress) -> {
try {
return collectDependencies(artifact, context.getRepositorySession());
} catch (ArtifactDescriptorException | DependencyCollectionException e) {
ArtifactKey key = new ArtifactKey(groupId, artifactId, version, null);
throw new CoreException(new Status(IStatus.ERROR, MicroProfileCorePlugin.PLUGIN_ID, "Error while collecting dependencies for " + key, e));
}
}, monitor);
if (result != null) {
Set<org.eclipse.lsp4mp.jdt.core.ArtifactResolver.Artifact> dependencies = new HashSet<>();
result.getRoot().accept(new DependencyVisitor() {
@Override
public boolean visitLeave(DependencyNode node) {
org.eclipse.aether.artifact.Artifact dep = node.getDependency().getArtifact();
dependencies.add(new org.eclipse.lsp4mp.jdt.core.ArtifactResolver.Artifact(dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getClassifier()));
return true;
}
@Override
public boolean visitEnter(DependencyNode node) {
return true;
}
});
return dependencies;
}
return Collections.emptySet();
}
Aggregations