本文整理汇总了Java中org.eclipse.aether.graph.Dependency类的典型用法代码示例。如果您正苦于以下问题:Java Dependency类的具体用法?Java Dependency怎么用?Java Dependency使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Dependency类属于org.eclipse.aether.graph包,在下文中一共展示了Dependency类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveArtifacts
import org.eclipse.aether.graph.Dependency; //导入依赖的package包/类
/**
* Given a set of coordinates, resolves the transitive dependencies, and then returns the root
* node to the resolved dependency graph. The root node is a sentinel node with direct edges
* on the artifacts users declared explicit on.
*/
public DependencyNode resolveArtifacts(List<String> artifactCoords) {
List<Dependency> directDependencies = createDirectDependencyList(artifactCoords);
CollectRequest collectRequest =
aether.createCollectRequest(directDependencies, managedDependencies);
DependencyRequest dependencyRequest = aether.createDependencyRequest(collectRequest);
DependencyResult dependencyResult;
try {
dependencyResult = aether.requestDependencyResolution(dependencyRequest);
} catch (DependencyResolutionException e) {
//FIXME(petros): This is very fragile. If one artifact doesn't resolve, no artifacts resolve.
logger.warning("Unable to resolve transitive dependencies: " + e.getMessage());
return null;
}
// root is a sentinel node whose direct children are the requested artifacts.
return dependencyResult.getRoot();
}
示例2: resolveArtifacts
import org.eclipse.aether.graph.Dependency; //导入依赖的package包/类
private Stream<? extends Artifact> resolveArtifacts(String coordinator) {
log.debug("resolving {}", coordinator);
try {
// build resolve filters
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(new DefaultArtifact(coordinator), JavaScopes.COMPILE));
DependencyRequest dependencyRequest = new DependencyRequest(
collectRequest,
DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE, JavaScopes.RUNTIME)
);
// resolve
final List<Artifact> artifacts = teslaAether.resolveArtifacts(dependencyRequest);
if (CollectionUtils.isEmpty(artifacts)) {
throw new DependencyResolveException(String.format("cannot resolve %s", coordinator));
}
return artifacts.stream();
} catch (DependencyResolutionException e) {
final String message = String.format("cannot resolve %s : %s", coordinator, e.getLocalizedMessage());
throw new DependencyResolveException(message, e);
}
}
示例3: collectDependencyArtifacts
import org.eclipse.aether.graph.Dependency; //导入依赖的package包/类
private List<Artifact> collectDependencyArtifacts(List<Dependency> dependencies)
throws RepositoryException {
CollectRequest collectRequest = new CollectRequest();
collectRequest.setDependencies(dependencies);
DependencyNode node = repositorySystem
.collectDependencies(repositorySystemSession, collectRequest)
.getRoot();
DependencyRequest dependencyRequest = new DependencyRequest();
dependencyRequest.setRoot(node);
// setFilter() allows null arguments.
dependencyRequest.setFilter(
AndDependencyFilter.newInstance(
new ScopeDependencyFilter(Arrays.asList(JavaScopes.COMPILE, JavaScopes.RUNTIME), null),
CloudKeeperBundleFilter.INSTANCE
)
);
repositorySystem.resolveDependencies(repositorySystemSession, dependencyRequest);
PreorderNodeListGenerator nodeListGenerator = new PreorderNodeListGenerator();
node.accept(nodeListGenerator);
return nodeListGenerator.getArtifacts(false);
}
示例4: loadDependencyDeclarations
import org.eclipse.aether.graph.Dependency; //导入依赖的package包/类
private List<MutableBundle> loadDependencyDeclarations(List<String> dependencies)
throws JAXBException, RepositoryException, XMLStreamException {
List<Dependency> aetherGraphDependencies = new ArrayList<>(dependencies.size());
for (String dependency: dependencies) {
aetherGraphDependencies.add(
new Dependency(new DefaultArtifact(GROUP_ID, dependency, "ckbundle", VERSION.toString()), "compile")
);
}
List<Artifact> bundleArtifacts = collectDependencyArtifacts(aetherGraphDependencies);
XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory();
List<MutableBundle> bundles = new ArrayList<>(bundleArtifacts.size());
for (Artifact bundleArtifact: bundleArtifacts) {
MutableBundle bundle = Bundles.loadBundle(jaxbContext, xmlInputFactory, bundleArtifact);
bundles.add(bundle);
}
return bundles;
}
示例5: addDependencyManagement
import org.eclipse.aether.graph.Dependency; //导入依赖的package包/类
public void addDependencyManagement(DependencyManagement dependencyManagement) {
for (org.springframework.boot.cli.compiler.dependencies.Dependency dependency : dependencyManagement
.getDependencies()) {
List<Exclusion> aetherExclusions = new ArrayList<Exclusion>();
for (org.springframework.boot.cli.compiler.dependencies.Dependency.Exclusion exclusion : dependency
.getExclusions()) {
aetherExclusions.add(new Exclusion(exclusion.getGroupId(),
exclusion.getArtifactId(), "*", "*"));
}
Dependency aetherDependency = new Dependency(
new DefaultArtifact(dependency.getGroupId(),
dependency.getArtifactId(), "jar", dependency.getVersion()),
JavaScopes.COMPILE, false, aetherExclusions);
this.managedDependencies.add(0, aetherDependency);
this.managedDependencyByGroupAndArtifact.put(getIdentifier(aetherDependency),
aetherDependency);
}
this.dependencyManagement = this.dependencyManagement == null
? dependencyManagement
: new CompositeDependencyManagement(dependencyManagement,
this.dependencyManagement);
this.artifactCoordinatesResolver = new DependencyManagementArtifactCoordinatesResolver(
this.dependencyManagement);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:25,代码来源:DependencyResolutionContext.java
示例6: resolve
import org.eclipse.aether.graph.Dependency; //导入依赖的package包/类
@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<URI>(files.size());
for (File file : files) {
uris.add(file.toURI());
}
return uris.toArray(new URI[uris.size()]);
}
catch (Exception ex) {
throw new DependencyResolutionFailedException(ex);
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:AetherGrapeEngine.java
示例7: resolve
import org.eclipse.aether.graph.Dependency; //导入依赖的package包/类
/**
* Builds the DependencyRequest, calls RepositorySystem.resolveDependencies and checks for any error.
*
* @return DependencyResult the returned result from resolveDependencies
* */
public DependencyResult resolve() throws Exception{
Dependency dependency=settings.getDependency().createDependency();
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(dependency);
collectRequest.setRepositories(settings.createRepositories());
DependencyRequest dependencyRequest=new DependencyRequest();
dependencyRequest.setCollectRequest(collectRequest);
DependencyResult result=repositorySystem.resolveDependencies(session, dependencyRequest);
if (result.getCollectExceptions()!=null && result.getCollectExceptions().size()>0){
throw result.getCollectExceptions().get(0);//return the first one. TODO: should return an exception wrapping them all
}
return result;
}
示例8: addDependencies
import org.eclipse.aether.graph.Dependency; //导入依赖的package包/类
private void addDependencies(Function<Artifact, Boolean> duplicateFilter, Optional<String> extension, Optional<String> classifier) {
List<Dependency> dependencies = input.stream()
.map(DependencyNode::getDependency)
.collect(Collectors.toList());
Set<String> existingGavs = dependencies.stream()
.map(Dependency::getArtifact)
.filter(duplicateFilter::apply)
.map(this::toGav)
.collect(Collectors.toSet());
List<DependencyNode> newNodes = input.stream()
.filter(n -> !existingGavs.contains(toGav(n.getDependency().getArtifact())))
.map(n -> createNode(n, extension, classifier))
.collect(Collectors.toList());
output.addAll(newNodes);
}
示例9: assertDependencyUpdated
import org.eclipse.aether.graph.Dependency; //导入依赖的package包/类
private void assertDependencyUpdated(final Artifact artifact, final String targetProject,
final String expectedVersion, final String expectedBuildNumber) throws Exception {
final RepositorySystemSession session = newRepositorySystemSession();
final ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
descriptorRequest.setArtifact(artifact);
final ArtifactDescriptorResult descriptorResult = system.readArtifactDescriptor(session, descriptorRequest);
Dependency targetDependency = null;
for (final Dependency dep : descriptorResult.getDependencies()) {
if (targetProject.equals(dep.getArtifact().getArtifactId())) {
targetDependency = dep;
break;
}
}
assertNotNull(format("No dependency found with artifact-id %s", targetProject), targetDependency);
assertEquals(format("%s%s", expectedVersion, expectedBuildNumber), targetDependency.getArtifact().getVersion());
}
示例10: getAllDependencies
import org.eclipse.aether.graph.Dependency; //导入依赖的package包/类
private ImmutableSet<ArtifactCoordinates> getAllDependencies(Artifact artifact, String scope)
throws DependencyCollectionException, DependencyResolutionException {
Dependency artifactAsDependency = new Dependency(artifact, scope);
CollectRequest collectRequest = new CollectRequest(artifactAsDependency, singletonList(mavenCentral));
DependencyNode dependencyRoot =
repositorySystem.collectDependencies(repositorySystemSession, collectRequest).getRoot();
DependencyRequest dependencyRequest = new DependencyRequest(dependencyRoot, null);
repositorySystem.resolveDependencies(repositorySystemSession, dependencyRequest);
PreorderNodeListGenerator dependencies = new PreorderNodeListGenerator();
dependencyRoot.getChildren().forEach(node -> node.accept(dependencies));
ImmutableSet.Builder<ArtifactCoordinates> dependencyCoordinates = ImmutableSet.builder();
dependencies.getArtifacts(true).stream().map(ArtifactCoordinates::from).forEach(dependencyCoordinates::add);
return dependencyCoordinates.build();
}
示例11: getRejectedDependencies
import org.eclipse.aether.graph.Dependency; //导入依赖的package包/类
public Set<Artifact> getRejectedDependencies(Artifact artifact) throws ArtifactDescriptorException {
Set<Dependency> allDependencies = getAllDependencies(artifact);
Set<Artifact> rejected = new HashSet<>();
for (Dependency dependency : allDependencies) {
Scope scope = Scope.compile;
try {
scope = Scope.valueOf(dependency.getScope().toLowerCase());
} catch (Throwable ignored) { }
if (ignoredScopes.contains(scope)) {
continue;
}
if ((dependency.getArtifact().isSnapshot() && rejectSnapshots) || notAllowed(allowedArtifacts, dependency)) {
rejected.add(dependency.getArtifact());
}
}
return rejected;
}
示例12: mavenDependencyToDependency
import org.eclipse.aether.graph.Dependency; //导入依赖的package包/类
private Dependency mavenDependencyToDependency(
org.apache.maven.model.Dependency dep) {
Artifact art = new DefaultArtifact(dep.getGroupId(),
dep.getArtifactId(),
dep.getClassifier(),
dep.getType(),
dep.getVersion());
Collection<Exclusion> excls = new HashSet<Exclusion>();
for (org.apache.maven.model.Exclusion excl :
dep.getExclusions()) {
excls.add(mavenExclusionToExclusion(excl));
}
return new Dependency(art,
dep.getScope(),
new Boolean(dep.isOptional()),
excls);
}
示例13: populateResult
import org.eclipse.aether.graph.Dependency; //导入依赖的package包/类
@Override
public void populateResult(RepositorySystemSession session,
ArtifactDescriptorResult result,
Model model) {
super.populateResult(session, result, model);
Parent parent = model.getParent();
if (parent != null) {
DefaultArtifact art =
new DefaultArtifact(parent.getGroupId(),
parent.getArtifactId(),
"pom",
parent.getVersion());
Dependency dep = new Dependency(art, "compile");
result.addDependency(dep);
}
}
开发者ID:NixOS,项目名称:mvn2nix-maven-plugin,代码行数:17,代码来源:ParentPOMPropagatingArtifactDescriptorReaderDelegate.java
示例14: transitiveDependencies
import org.eclipse.aether.graph.Dependency; //导入依赖的package包/类
public static Set<Artifact> transitiveDependencies(Artifact artifact) {
RepositorySystem system = newRepositorySystem();
RepositorySystemSession session = newRepositorySystemSession(system);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, ""));
collectRequest.setRepositories(repositories());
CollectResult collectResult = null;
try {
collectResult = system.collectDependencies(session, collectRequest);
} catch (DependencyCollectionException e) {
throw new RuntimeException(e);
}
PreorderNodeListGenerator visitor = new PreorderNodeListGenerator();
collectResult.getRoot().accept(visitor);
return ImmutableSet.copyOf(
visitor.getNodes().stream()
.filter(d -> !d.getDependency().isOptional())
.map(DependencyNode::getArtifact)
.collect(Collectors.toList()));
}
示例15: getDependencies
import org.eclipse.aether.graph.Dependency; //导入依赖的package包/类
public List<Artifact> getDependencies(String groupId, String artifactId, String extension, String version) throws Exception {
Artifact artifact = new DefaultArtifact(groupId, artifactId, extension, version);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency( artifact, ""));
collectRequest.setRepositories(Collections.emptyList());
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE));
DependencyResult dependencyResult = system.resolveDependencies(session, dependencyRequest);
List<Artifact> dependencies = new ArrayList<>();
for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) {
if (!artifactResult.isResolved()) {
throw new Exception("Could not resolve artifact " + artifactResult.getRequest().getArtifact());
}
dependencies.add(artifactResult.getArtifact());
}
return dependencies;
}