use of org.eclipse.aether.graph.DependencyNode in project maven by apache.
the class DefaultMavenPluginManager method resolveExtensionArtifacts.
private List<Artifact> resolveExtensionArtifacts(Plugin extensionPlugin, List<RemoteRepository> repositories, RepositorySystemSession session) throws PluginResolutionException {
DependencyNode root = pluginDependenciesResolver.resolve(extensionPlugin, null, null, repositories, session);
PreorderNodeListGenerator nlg = new PreorderNodeListGenerator();
root.accept(nlg);
return toMavenArtifacts(root, nlg);
}
use of org.eclipse.aether.graph.DependencyNode in project maven by apache.
the class DefaultPluginDependenciesResolver method resolveInternal.
private DependencyNode resolveInternal(Plugin plugin, Artifact pluginArtifact, DependencyFilter dependencyFilter, List<RemoteRepository> repositories, RepositorySystemSession session) throws PluginResolutionException {
RequestTrace trace = RequestTrace.newChild(null, plugin);
if (pluginArtifact == null) {
pluginArtifact = toArtifact(plugin, session);
}
DependencyFilter collectionFilter = new ScopeDependencyFilter("provided", "test");
DependencyFilter resolutionFilter = AndDependencyFilter.newInstance(collectionFilter, dependencyFilter);
DependencyNode node;
try {
DependencySelector selector = AndDependencySelector.newInstance(session.getDependencySelector(), new WagonExcluder());
DefaultRepositorySystemSession pluginSession = new DefaultRepositorySystemSession(session);
pluginSession.setDependencySelector(selector);
pluginSession.setDependencyGraphTransformer(session.getDependencyGraphTransformer());
CollectRequest request = new CollectRequest();
request.setRequestContext(REPOSITORY_CONTEXT);
request.setRepositories(repositories);
request.setRoot(new org.eclipse.aether.graph.Dependency(pluginArtifact, null));
for (Dependency dependency : plugin.getDependencies()) {
org.eclipse.aether.graph.Dependency pluginDep = RepositoryUtils.toDependency(dependency, session.getArtifactTypeRegistry());
if (!JavaScopes.SYSTEM.equals(pluginDep.getScope())) {
pluginDep = pluginDep.setScope(JavaScopes.RUNTIME);
}
request.addDependency(pluginDep);
}
DependencyRequest depRequest = new DependencyRequest(request, resolutionFilter);
depRequest.setTrace(trace);
request.setTrace(RequestTrace.newChild(trace, depRequest));
node = repoSystem.collectDependencies(pluginSession, request).getRoot();
if (logger.isDebugEnabled()) {
node.accept(new GraphLogger());
}
depRequest.setRoot(node);
repoSystem.resolveDependencies(session, depRequest);
} catch (DependencyCollectionException e) {
throw new PluginResolutionException(plugin, e);
} catch (DependencyResolutionException e) {
throw new PluginResolutionException(plugin, e.getCause());
}
return node;
}
use of org.eclipse.aether.graph.DependencyNode in project maven by apache.
the class BootstrapCoreExtensionManager method resolveExtension.
private List<Artifact> resolveExtension(CoreExtension extension, RepositorySystemSession repoSession, List<RemoteRepository> repositories, DependencyFilter dependencyFilter, Interpolator interpolator) throws ExtensionResolutionException {
try {
/* TODO: Enhance the PluginDependenciesResolver to provide a
* resolveCoreExtension method which uses a CoreExtension
* object instead of a Plugin as this makes no sense.
*/
Plugin plugin = new Plugin();
plugin.setGroupId(interpolator.interpolate(extension.getGroupId()));
plugin.setArtifactId(interpolator.interpolate(extension.getArtifactId()));
plugin.setVersion(interpolator.interpolate(extension.getVersion()));
DependencyNode root = pluginDependenciesResolver.resolveCoreExtension(plugin, dependencyFilter, repositories, repoSession);
PreorderNodeListGenerator nlg = new PreorderNodeListGenerator();
root.accept(nlg);
return nlg.getArtifacts(false);
} catch (PluginResolutionException e) {
throw new ExtensionResolutionException(extension, e.getCause());
} catch (InterpolationException e) {
throw new ExtensionResolutionException(extension, e);
}
}
use of org.eclipse.aether.graph.DependencyNode in project maven by apache.
the class RepositoryUtils method toArtifacts.
public static void toArtifacts(Collection<org.apache.maven.artifact.Artifact> artifacts, Collection<? extends DependencyNode> nodes, List<String> trail, DependencyFilter filter) {
for (DependencyNode node : nodes) {
org.apache.maven.artifact.Artifact artifact = toArtifact(node.getDependency());
List<String> nodeTrail = new ArrayList<>(trail.size() + 1);
nodeTrail.addAll(trail);
nodeTrail.add(artifact.getId());
if (filter == null || filter.accept(node, Collections.emptyList())) {
artifact.setDependencyTrail(nodeTrail);
artifacts.add(artifact);
}
toArtifacts(artifacts, node.getChildren(), nodeTrail, filter);
}
}
use of org.eclipse.aether.graph.DependencyNode in project quarkus by quarkusio.
the class BootstrapAppModelResolver method doResolveModel.
private ApplicationModel doResolveModel(ArtifactCoords coords, List<Dependency> directMvnDeps, ArtifactCoords managingProject, Set<ArtifactKey> reloadableModules) throws AppModelResolverException {
if (coords == null) {
throw new IllegalArgumentException("Application artifact is null");
}
final Artifact mvnArtifact = toAetherArtifact(coords);
List<Dependency> managedDeps = List.of();
List<RemoteRepository> managedRepos = List.of();
if (managingProject != null) {
final ArtifactDescriptorResult managingDescr = mvn.resolveDescriptor(toAetherArtifact(managingProject));
managedDeps = managingDescr.getManagedDependencies();
managedRepos = mvn.newResolutionRepositories(managingDescr.getRepositories());
}
final ResolvedDependency appArtifact = resolve(coords, mvnArtifact, managedRepos);
final List<String> excludedScopes;
if (test) {
excludedScopes = List.of();
} else if (devmode) {
excludedScopes = List.of("test");
} else {
excludedScopes = List.of("provided", "test");
}
final DependencyNode resolvedDeps = mvn.resolveManagedDependencies(mvnArtifact, directMvnDeps, managedDeps, managedRepos, excludedScopes.toArray(new String[0])).getRoot();
ArtifactDescriptorResult appArtifactDescr = mvn.resolveDescriptor(toAetherArtifact(appArtifact));
if (managingProject == null) {
managedDeps = appArtifactDescr.getManagedDependencies();
} else {
final List<Dependency> mergedManagedDeps = new ArrayList<>(managedDeps.size());
final Set<ArtifactKey> mergedKeys = new HashSet<>(managedDeps.size());
for (Dependency dep : managedDeps) {
mergedKeys.add(getKey(dep.getArtifact()));
mergedManagedDeps.add(dep);
}
for (Dependency dep : appArtifactDescr.getManagedDependencies()) {
final Artifact artifact = dep.getArtifact();
if (!mergedKeys.contains(getKey(artifact))) {
mergedManagedDeps.add(dep);
}
}
managedDeps = mergedManagedDeps;
}
final List<RemoteRepository> repos = mvn.aggregateRepositories(managedRepos, mvn.newResolutionRepositories(appArtifactDescr.getRepositories()));
return buildAppModel(appArtifact, resolvedDeps, reloadableModules, managedDeps, repos);
}
Aggregations