use of org.eclipse.aether.graph.DependencyNode in project fabric8 by jboss-fuse.
the class ReplaceConflictingVersionResolver method transformGraph.
public DependencyNode transformGraph(DependencyNode node, DependencyGraphTransformationContext context) throws RepositoryException {
List<?> sortedConflictIds = (List<?>) context.get(TransformationContextKeys.SORTED_CONFLICT_IDS);
if (sortedConflictIds == null) {
ConflictIdSorter sorter = new ConflictIdSorter();
sorter.transformGraph(node, context);
sortedConflictIds = (List<?>) context.get(TransformationContextKeys.SORTED_CONFLICT_IDS);
}
Map<?, ?> conflictIds = (Map<?, ?>) context.get(TransformationContextKeys.CONFLICT_IDS);
if (conflictIds == null) {
throw new RepositoryException("conflict groups have not been identified");
}
Map<DependencyNode, Integer> depths = new TreeMap<DependencyNode, Integer>(DependencyNodeComparator.INSTANCE);
for (Object key : sortedConflictIds) {
ConflictGroup group = new ConflictGroup(key);
depths.clear();
selectVersion(node, null, 0, depths, group, conflictIds);
updateNonSelectedVersions(group, conflictIds);
}
return node;
}
use of org.eclipse.aether.graph.DependencyNode in project wildfly-swarm by wildfly-swarm.
the class MavenArtifactResolvingHelper method resolveAll.
@Override
public Set<ArtifactSpec> resolveAll(Collection<ArtifactSpec> specs, boolean transitive, boolean defaultExcludes) throws Exception {
if (specs.isEmpty()) {
return Collections.emptySet();
}
List<DependencyNode> nodes;
if (transitive) {
final CollectRequest request = new CollectRequest();
request.setRepositories(this.remoteRepositories);
// SWARM-1031
if (this.dependencyManagement != null) {
List<Dependency> managedDependencies = this.dependencyManagement.getDependencies().stream().map(mavenDep -> {
DefaultArtifact artifact = new DefaultArtifact(mavenDep.getGroupId(), mavenDep.getArtifactId(), mavenDep.getType(), mavenDep.getVersion());
return new Dependency(artifact, mavenDep.getScope());
}).collect(Collectors.toList());
request.setManagedDependencies(managedDependencies);
}
specs.forEach(spec -> request.addDependency(new Dependency(new DefaultArtifact(spec.groupId(), spec.artifactId(), spec.classifier(), spec.type(), spec.version()), "compile")));
RepositorySystemSession tempSession = new RepositorySystemSessionWrapper(this.session, new ConflictResolver(new NearestVersionSelector(), new JavaScopeSelector(), new SimpleOptionalitySelector(), new JavaScopeDeriver()), defaultExcludes);
CollectResult result = this.system.collectDependencies(tempSession, request);
PreorderNodeListGenerator gen = new PreorderNodeListGenerator();
result.getRoot().accept(gen);
nodes = gen.getNodes();
} else {
nodes = new ArrayList<>();
for (ArtifactSpec spec : specs) {
Dependency dependency = new Dependency(new DefaultArtifact(spec.groupId(), spec.artifactId(), spec.classifier(), spec.type(), spec.version()), "compile");
DefaultDependencyNode node = new DefaultDependencyNode(dependency);
nodes.add(node);
}
}
List<DependencyNode> extraDependencies = ExtraArtifactsHandler.getExtraDependencies(nodes);
nodes.addAll(extraDependencies);
resolveDependenciesInParallel(nodes);
return nodes.stream().filter(node -> !"system".equals(node.getDependency().getScope())).map(node -> {
final Artifact artifact = node.getArtifact();
return new ArtifactSpec(node.getDependency().getScope(), artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getExtension(), artifact.getClassifier(), null);
}).map(this::resolve).filter(Objects::nonNull).collect(Collectors.toSet());
}
use of org.eclipse.aether.graph.DependencyNode in project wildfly-swarm by wildfly-swarm.
the class ExtraArtifactsHandlerTest method shouldGetWithClassifierAndExtension.
private void shouldGetWithClassifierAndExtension(String classifier, String extension) {
DependencyNode dependency = dependencyNode();
List<DependencyNode> extraDependencies = ExtraArtifactsHandler.getExtraDependencies(Collections.singletonList(dependency));
assertThat(extraDependencies).hasSize(1);
DependencyNode extraDependency = extraDependencies.get(0);
Artifact artifact = extraDependency.getDependency().getArtifact();
assertThat(artifact.getGroupId()).isEqualTo(GROUP_ID);
assertThat(artifact.getArtifactId()).isEqualTo(ARTIFACT_ID);
assertThat(artifact.getVersion()).isEqualTo(VERSION);
assertThat(artifact.getClassifier()).isEqualTo(classifier);
assertThat(artifact.getExtension()).isEqualTo(extension);
}
use of org.eclipse.aether.graph.DependencyNode 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);
}
}
use of org.eclipse.aether.graph.DependencyNode in project mule by mulesoft.
the class DependencyResolver method logUnresolvedArtifacts.
/**
* Logs the paths for each dependency not found
*
* @param node root {@link DependencyNode}, can be a "null" root (imaginary root)
* @param e {@link DependencyResolutionException} the error to collect paths.
*/
private void logUnresolvedArtifacts(DependencyNode node, DependencyResolutionException e) {
List<ArtifactResult> artifactResults = e.getResult().getArtifactResults().stream().filter(artifactResult -> !artifactResult.getExceptions().isEmpty()).collect(toList());
final List<String> patternInclusion = artifactResults.stream().map(artifactResult -> toId(artifactResult.getRequest().getArtifact())).collect(toList());
PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor(new PatternInclusionsDependencyFilter(patternInclusion), node.getArtifact() != null);
node.accept(visitor);
visitor.getPaths().stream().forEach(path -> {
List<DependencyNode> unresolvedArtifactPath = path.stream().filter(dependencyNode -> dependencyNode.getArtifact() != null).collect(toList());
if (!unresolvedArtifactPath.isEmpty()) {
logger.warn("Dependency path to not resolved artifacts -> {}", unresolvedArtifactPath.toString());
}
});
}
Aggregations