use of org.eclipse.aether.artifact.Artifact in project atlasmap by atlasmap.
the class GenerateInspectionsMojo method resolveClasspath.
private List<URL> resolveClasspath(List<String> artifacts) throws MojoFailureException {
final List<URL> urls = new ArrayList<>();
try {
for (String gav : artifacts) {
Artifact artifact = new DefaultArtifact(gav);
getLog().debug("Resolving dependencies for artifact: " + artifact);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, ""));
collectRequest.setRepositories(remoteRepos);
DependencyRequest dependencyRequest = new DependencyRequest();
dependencyRequest.setCollectRequest(collectRequest);
DependencyResult dependencyResult = system.resolveDependencies(repoSession, dependencyRequest);
PreorderNodeListGenerator nlg = new PreorderNodeListGenerator();
dependencyResult.getRoot().accept(nlg);
Iterator<DependencyNode> it = nlg.getNodes().iterator();
while (it.hasNext()) {
DependencyNode node = it.next();
if (node.getDependency() != null) {
Artifact x = node.getDependency().getArtifact();
if (x.getFile() != null) {
getLog().debug("Found dependency: " + x + " for artifact: " + artifact);
urls.add(x.getFile().toURI().toURL());
}
}
}
}
} catch (IllegalArgumentException e) {
throw new MojoFailureException(e.getMessage(), e);
} catch (DependencyResolutionException e) {
throw new MojoFailureException(e.getMessage(), e);
} catch (MalformedURLException e) {
throw new MojoFailureException(e.getMessage(), e);
}
return urls;
}
use of org.eclipse.aether.artifact.Artifact in project drools by kiegroup.
the class KieRepositoryScannerImpl method addDependencies.
private void addDependencies(InternalKieModule kieModule, ArtifactResolver resolver, List<DependencyDescriptor> dependencies) {
for (DependencyDescriptor dep : dependencies) {
InternalKieModule dependency = (InternalKieModule) KieServices.Factory.get().getRepository().getKieModule(adapt(dep.getReleaseId()));
if (dependency != null) {
kieModule.addKieDependency(dependency);
} else {
Artifact depArtifact = resolver.resolveArtifact(dep.getReleaseId());
if (depArtifact != null && isKJar(depArtifact.getFile())) {
ReleaseId depReleaseId = adapt(new DependencyDescriptor(depArtifact).getReleaseId());
InternalKieModule zipKieModule = createKieModule(depReleaseId, depArtifact.getFile());
if (zipKieModule != null) {
kieModule.addKieDependency(zipKieModule);
}
}
}
}
}
use of org.eclipse.aether.artifact.Artifact in project bazel by bazelbuild.
the class Resolver method resolveArtifact.
/**
* Resolves an artifact as a root of a dependency graph.
*/
public void resolveArtifact(String artifactCoord) {
Artifact artifact;
ModelSource modelSource;
try {
artifact = getArtifact(artifactCoord);
modelSource = modelResolver.resolveModel(artifact);
} catch (UnresolvableModelException | InvalidArtifactCoordinateException e) {
handler.handle(Event.error(e.getMessage()));
return;
}
Rule rule = new Rule(artifact);
// add the artifact rule to the workspace
deps.put(rule.name(), rule);
resolveEffectiveModel(modelSource, Sets.<String>newHashSet(), rule);
}
use of org.eclipse.aether.artifact.Artifact in project buck by facebook.
the class ResolverIntegrationTest method shouldDetectNewestJar.
@Test
public void shouldDetectNewestJar() throws Exception {
Path groupDir = thirdParty.resolve("example");
Path existingNewerJar = groupDir.resolve("no-deps-1.1.jar");
Path existingNewestJar = groupDir.resolve("no-deps-1.2.jar");
Files.createDirectories(groupDir);
Path sourceJar = repo.resolve("com/example/no-deps/1.0/no-deps-1.0.jar");
Files.copy(sourceJar, existingNewerJar);
Files.copy(sourceJar, existingNewestJar);
Artifact artifact = new DefaultArtifact("com.example", "no-deps", "jar", "1.0");
Optional<Path> result = new Resolver(newConfig()).getNewerVersionFile(artifact, groupDir);
assertTrue(result.isPresent());
assertThat(result.get(), equalTo(existingNewestJar));
}
use of org.eclipse.aether.artifact.Artifact in project buck by facebook.
the class Resolver method buildDependencyGraph.
private MutableDirectedGraph<Artifact> buildDependencyGraph(Map<String, Artifact> knownDeps) throws ArtifactDescriptorException {
MutableDirectedGraph<Artifact> graph;
graph = new MutableDirectedGraph<>();
for (Map.Entry<String, Artifact> entry : knownDeps.entrySet()) {
String key = entry.getKey();
Artifact artifact = entry.getValue();
graph.addNode(artifact);
List<Dependency> dependencies = getDependenciesOf(artifact);
for (Dependency dependency : dependencies) {
if (dependency.getArtifact() == null) {
System.out.println("Skipping because artifact missing: " + dependency);
continue;
}
String depKey = buildKey(dependency.getArtifact());
Artifact actualDep = knownDeps.get(depKey);
if (actualDep == null) {
continue;
}
// It's possible that the runtime dep of an artifact is the test time dep of another.
if (isTestTime(dependency)) {
continue;
}
// TODO(shs96c): Do we always want optional dependencies?
// if (dependency.isOptional()) {
// continue;
// }
Preconditions.checkNotNull(actualDep, key + " -> " + artifact + " in " + knownDeps.keySet());
graph.addNode(actualDep);
graph.addEdge(actualDep, artifact);
}
}
return graph;
}
Aggregations