use of org.eclipse.aether.graph.Dependency in project druid by druid-io.
the class PullDependenciesTest method getArtifactsForExtension.
private List<Artifact> getArtifactsForExtension(Artifact artifact, DependencyFilter filter) {
final List<String> names = extensionToDependency.get(artifact);
final List<Artifact> artifacts = new ArrayList<>();
for (String name : names) {
final File jarFile = new File(localRepo, name + ".jar");
try {
jarFile.createNewFile();
} catch (IOException e) {
throw new RuntimeException(e);
}
DependencyNode node = new DefaultDependencyNode(new Dependency(new DefaultArtifact(DEPENDENCY_GROUPID, name, null, "jar", "1.0", null, jarFile), "compile"));
if (filter.accept(node, Collections.emptyList())) {
artifacts.add(node.getArtifact());
}
}
return artifacts;
}
use of org.eclipse.aether.graph.Dependency in project jqa-core-framework by buschmais.
the class AetherPluginResolverImpl method createClassLoader.
@Override
public PluginClassLoader createClassLoader(ClassLoader parent, List<Plugin> plugins) {
List<Dependency> requiredPlugins = getRequiredPluginDependencies(plugins);
DependencyResult dependencyResult = resolvePlugins(requiredPlugins);
return new PluginClassLoader(getDependencyURLs(dependencyResult), parent);
}
use of org.eclipse.aether.graph.Dependency in project spring-boot by spring-projects.
the class MavenResolverGrapeEngine method resolve.
@Override
public URI[] resolve(Map args, List depsInfo, Map... dependencyMaps) {
List<Exclusion> exclusions = createExclusions(args);
List<Dependency> dependencies = createDependencies(dependencyMaps, exclusions);
try {
List<File> files = resolve(dependencies);
List<URI> uris = new ArrayList<>(files.size());
for (File file : files) {
uris.add(file.toURI());
}
return uris.toArray(new URI[0]);
} catch (Exception ex) {
throw new DependencyResolutionFailedException(ex);
}
}
use of org.eclipse.aether.graph.Dependency in project atlasmap by atlasmap.
the class AbstractAtlasMapMojo method resolveClasspath.
/**
* Resolves the classpath.
* @param artifacts artifacts
* @return resolved
* @throws MojoFailureException unexpected error
*/
protected 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(getRemoteRepos());
DependencyRequest dependencyRequest = new DependencyRequest();
dependencyRequest.setCollectRequest(collectRequest);
DependencyResult dependencyResult = getSystem().resolveDependencies(getRepoSession(), 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.graph.Dependency in project qpid-broker-j by apache.
the class ClasspathQuery method getJarFiles.
private static Set<File> getJarFiles(final Collection<String> gavs) {
Set<File> jars = new HashSet<>();
for (final String gav : gavs) {
Artifact artifact = new DefaultArtifact(gav);
DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
collectRequest.setRepositories(Booter.newRepositories());
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFlter);
List<ArtifactResult> artifactResults = null;
try {
artifactResults = _mavenRepositorySystem.resolveDependencies(_mavenRepositorySession, dependencyRequest).getArtifactResults();
} catch (DependencyResolutionException e) {
throw new RuntimeException(String.format("Error while dependency resolution for '%s'", gav), e);
}
if (artifactResults == null) {
throw new RuntimeException(String.format("Could not resolve dependency for '%s'", gav));
}
for (ArtifactResult artifactResult : artifactResults) {
System.out.println(artifactResult.getArtifact() + " resolved to " + artifactResult.getArtifact().getFile());
}
jars.addAll(artifactResults.stream().map(result -> result.getArtifact().getFile()).collect(Collectors.toSet()));
}
return jars;
}
Aggregations