本文整理汇总了Java中org.eclipse.aether.graph.DependencyNode.accept方法的典型用法代码示例。如果您正苦于以下问题:Java DependencyNode.accept方法的具体用法?Java DependencyNode.accept怎么用?Java DependencyNode.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.aether.graph.DependencyNode
的用法示例。
在下文中一共展示了DependencyNode.accept方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBasicGraphConstruction
import org.eclipse.aether.graph.DependencyNode; //导入方法依赖的package包/类
@Test
public void testBasicGraphConstruction() {
DependencyNode root = dependencyNode("root:root:1");
DependencyNode depA = dependencyNode("a:a:1");
DependencyNode depB = dependencyNode("b:b:1");
root.setChildren(ImmutableList.of(depA, depB));
MavenJarRule rootRule = new MavenJarRule(root);
MavenJarRule aRule = new MavenJarRule(depA);
MavenJarRule bRule = new MavenJarRule(depB);
MutableGraph<MavenJarRule> expected = newGraph();
addEdge(expected, rootRule, aRule);
addEdge(expected, rootRule, bRule);
// Construct the graph
MutableGraph<MavenJarRule> actual = newGraph();
AetherGraphTraverser visitor = new AetherGraphTraverser(actual);
root.accept(visitor);
assertThatGraphsEqual(actual, expected);
}
示例2: collectDependencyArtifacts
import org.eclipse.aether.graph.DependencyNode; //导入方法依赖的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);
}
示例3: downloadDependencyTree
import org.eclipse.aether.graph.DependencyNode; //导入方法依赖的package包/类
/**
* Resolves and downloads an artifact with its dependencies.
*
* @param artifact
* artifact to resolve
* @param javadoc
* <code>true</code> if javadoc attachment should be retrieved too
* @param sources
* <code>true</code> if sources attachment should be retrieved too
* @throws DependencyCollectionException
* if the dependency graph could not be properly assembled
* @throws DependencyResolutionException
* if a dependency is not resolvable
*/
public void downloadDependencyTree(DefaultArtifact artifact, boolean javadoc, boolean sources)
throws DependencyCollectionException, DependencyResolutionException {
log.info("Resolving: {} with these dependencies ...", artifact.toString());
Dependency dependency = new Dependency(artifact, JavaScopes.COMPILE);
DependencyNode jarNode = repoSystemHelper.collectDependencies(dependency);
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.TEST);
jarNode.accept(new TreeDependencyVisitor(new FilteringDependencyVisitor(new DependencyGraphPrinter(), classpathFilter)));
DependencyRequest dependencyRequest = new DependencyRequest(jarNode, classpathFilter);
DependencyResult dependencyResult = repoSystemHelper.resolveDependencies(dependencyRequest);
if (javadoc) {
downloadAttachments(dependencyResult, "javadoc");
}
if (sources) {
downloadAttachments(dependencyResult, "sources");
}
}
示例4: resolveAsDependencyNode
import org.eclipse.aether.graph.DependencyNode; //导入方法依赖的package包/类
private List<DependencyNode> resolveAsDependencyNode(final Artifact artifact) throws DependencyCollectionException, DependencyResolutionException {
final CollectResult collect_result = collectDependencies(artifact, repositories);
final DependencyNode root_dependency = collect_result.getRoot();
final DependencyRequest dep_request = new DependencyRequest();
final DependencyNodeCollector node_collector = new DependencyNodeCollector();
dep_request.setRoot(root_dependency);
REPOSITORY_SYSTEM.resolveDependencies(session, dep_request);
root_dependency.accept(node_collector);
return node_collector.nodes;
}
示例5: testAccumulation
import org.eclipse.aether.graph.DependencyNode; //导入方法依赖的package包/类
/**
* Asserts that when the dependency visitor is accepted by multiple
* nodes, the constructed graph contains nodes and edges from all visits.
*/
@Test
public void testAccumulation() {
DependencyNode rootNodeA = dependencyNode("a:a1:1");
DependencyNode childNodeA = dependencyNode("a:a2:1");
DependencyNode rootNodeB = dependencyNode("b:b1:1");
DependencyNode childNodeB = dependencyNode("b:b2:1");
rootNodeA.setChildren(ImmutableList.of(childNodeA));
rootNodeB.setChildren(ImmutableList.of(childNodeB));
MavenJarRule rootRuleA = new MavenJarRule(rootNodeA);
MavenJarRule childRuleA = new MavenJarRule(childNodeA);
MavenJarRule rootRuleB = new MavenJarRule(rootNodeB);
MavenJarRule childRuleB = new MavenJarRule(childNodeB);
MutableGraph<MavenJarRule> expected = newGraph();
addEdge(expected, rootRuleA, childRuleA);
addEdge(expected, rootRuleB, childRuleB);
// Construct the graph
MutableGraph<MavenJarRule> actual = newGraph();
AetherGraphTraverser visitor = new AetherGraphTraverser(actual);
rootNodeA.accept(visitor);
rootNodeB.accept(visitor);
assertThatGraphsEqual(actual, expected);
}
示例6: testDuplicateChildren
import org.eclipse.aether.graph.DependencyNode; //导入方法依赖的package包/类
/**
* Tests behavior when there is a duplicate dependency node within the graph, meaning
* two nodes with the same maven coordinate. The generated graph should not contain
* multiple instances of that node.
*/
@Test
public void testDuplicateChildren() {
DependencyNode rootNodeA = dependencyNode("a:a:1");
DependencyNode rootNodeB = dependencyNode("b:b:1");
DependencyNode childNode = dependencyNode("c:c:1");
DependencyNode childNodeDuplicate = dependencyNode("c:c:1");
rootNodeA.setChildren(ImmutableList.of(childNode));
rootNodeB.setChildren(ImmutableList.of(childNode));
rootNodeA.setChildren(ImmutableList.of(childNodeDuplicate));
rootNodeB.setChildren(ImmutableList.of(childNodeDuplicate));
MavenJarRule rootRuleA = new MavenJarRule(rootNodeA);
MavenJarRule childRule = new MavenJarRule(childNode);
MavenJarRule rootRuleB = new MavenJarRule(rootNodeB);
MutableGraph<MavenJarRule> expected = newGraph();
addEdge(expected, rootRuleA, childRule);
addEdge(expected, rootRuleB, childRule);
// Construct the graph
MutableGraph<MavenJarRule> actual = newGraph();
AetherGraphTraverser visitor = new AetherGraphTraverser(actual);
rootNodeA.accept(visitor);
rootNodeB.accept(visitor);
assertThatGraphsEqual(actual, expected);
}
示例7: resolveArtifacts
import org.eclipse.aether.graph.DependencyNode; //导入方法依赖的package包/类
/**
* Returns a filtered list of artifacts that the given (unresolved) artifact has as dependencies.
*
* <p>The first artifact is converted into the root dependency that is passed to
* {@link CollectRequest#CollectRequest(Dependency, List, List)}. The root dependency is used, among other things,
* to determine the managed dependencies. In other words, {@code unresolvedArtifacts} should not be treated as set,
* the order (and in particular, which element comes first) is significant.
*
* @param dependencyFilter filter for nodes in the dependency graph; may be null
* @param unresolvedArtifacts the artifacts that should be resolved, including their version-managed and merged
* transitive dependencies
* @param scope Scope of root node in the dependency graph. If {@code dependencyFilter} filters on the scope, then
* this should match the requested scope. Otherwise, this parameter will not have an effect. May be
* {@code null}.
* @return List of artifacts that the given (unresolved) artifact has as dependencies. The list only contains the
* artifacts of {@link DependencyNode} instances for that {@code dependencyFilter} returns {@code true}.
* Note that the returned list is inclusive of {@code unresolvedArtifact}.
* @throws NullPointerException if {@code unresolvedArtifact} is {@code null}
* @throws RepositoryException if one or more artifacts cannot be resolved
*/
public List<Artifact> resolveArtifacts(@Nullable DependencyFilter dependencyFilter,
List<Artifact> unresolvedArtifacts, @Nullable String scope) throws RepositoryException {
List<Dependency> dependencies = unresolvedArtifacts.stream()
.map(unresolved -> new Dependency(unresolved, scope))
.collect(Collectors.toList());
if (dependencies.isEmpty()) {
return Collections.emptyList();
}
CollectRequest collectRequest
= new CollectRequest(dependencies.get(0), dependencies.subList(1, dependencies.size()), remoteRepositories);
DependencyNode node = repositorySystem
.collectDependencies(repositorySystemSession, collectRequest)
.getRoot();
DependencyRequest dependencyRequest = new DependencyRequest();
dependencyRequest.setRoot(node);
// setFilter() allows null arguments.
dependencyRequest.setFilter(dependencyFilter);
repositorySystem.resolveDependencies(repositorySystemSession, dependencyRequest);
PreorderNodeListGenerator nodeListGenerator = new PreorderNodeListGenerator();
node.accept(nodeListGenerator);
return nodeListGenerator.getArtifacts(false);
}
示例8: findPathToDependency
import org.eclipse.aether.graph.DependencyNode; //导入方法依赖的package包/类
public static String findPathToDependency(Artifact artifact, DependencyNode root) {
StringBuilder pathBuilder = new StringBuilder();
PathRecordingDependencyVisitor pathVisitor = new PathRecordingDependencyVisitor(new PatternInclusionsDependencyFilter(artifact.toString()));
root.accept(pathVisitor);
List<List<DependencyNode>> paths = pathVisitor.getPaths();
for (List<DependencyNode> path : paths) {
for (int i = 0; i < path.size(); i++) {
pathBuilder.append(path.get(i).getArtifact());
if (i != path.size() - 1) {
pathBuilder.append(" > ");
}
}
}
return pathBuilder.toString();
}