use of org.eclipse.aether.artifact.Artifact in project zeppelin by apache.
the class DependencyResolver method getArtifactsWithDep.
/**
* @param dependency
* @param excludes list of pattern can either be of the form groupId:artifactId
* @return
* @throws Exception
*/
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency, Collection<String> excludes) throws RepositoryException {
Artifact artifact = new DefaultArtifact(dependency);
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(excludes);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
synchronized (repos) {
for (RemoteRepository repo : repos) {
collectRequest.addRepository(repo);
}
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
try {
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
} catch (NullPointerException | DependencyResolutionException ex) {
throw new RepositoryException(String.format("Cannot fetch dependencies for %s", dependency), ex);
}
}
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;
}
use of org.eclipse.aether.artifact.Artifact in project buck by facebook.
the class Resolver method downloadArtifact.
private Map.Entry<Path, Prebuilt> downloadArtifact(final Artifact artifactToDownload, TraversableGraph<Artifact> graph, ImmutableMap<String, Dependency> specifiedDependencies) throws IOException, ArtifactResolutionException {
String projectName = getProjectName(artifactToDownload);
Path project = buckRepoRoot.resolve(buckThirdPartyRelativePath).resolve(projectName);
Files.createDirectories(project);
Prebuilt library = resolveLib(artifactToDownload, project);
// Populate deps
Iterable<Artifact> incoming = graph.getIncomingNodesFor(artifactToDownload);
for (Artifact artifact : incoming) {
String groupName = getProjectName(artifact);
if (projectName.equals(groupName)) {
library.addDep(String.format(":%s", artifact.getArtifactId()));
} else {
library.addDep(buckThirdPartyRelativePath, artifact);
}
}
// Populate visibility
Iterable<Artifact> outgoing = graph.getOutgoingNodesFor(artifactToDownload);
for (Artifact artifact : outgoing) {
String groupName = getProjectName(artifact);
if (!groupName.equals(projectName)) {
library.addVisibility(buckThirdPartyRelativePath, artifact);
}
}
if (specifiedDependencies.containsKey(buildKey(artifactToDownload))) {
for (String rule : visibility) {
library.addVisibility(rule);
}
}
return Maps.immutableEntry(project, library);
}
Aggregations