本文整理汇总了Java中org.eclipse.aether.graph.DependencyNode类的典型用法代码示例。如果您正苦于以下问题:Java DependencyNode类的具体用法?Java DependencyNode怎么用?Java DependencyNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DependencyNode类属于org.eclipse.aether.graph包,在下文中一共展示了DependencyNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolve
import org.eclipse.aether.graph.DependencyNode; //导入依赖的package包/类
@Override
public DependencyNode resolve(Plugin plugin, Artifact pluginArtifact, DependencyFilter dependencyFilter, List<RemoteRepository> repositories, RepositorySystemSession session) throws PluginResolutionException {
WorkspaceReader wr = session.getWorkspaceReader();
NbWorkspaceReader nbwr = null;
if (wr instanceof NbWorkspaceReader) {
nbwr = (NbWorkspaceReader)wr;
//this only works reliably because the NbWorkspaceReader is part of the session, not a component
nbwr.silence();
}
try {
return super.resolve(plugin, pluginArtifact, dependencyFilter, repositories, session);
} finally {
if (nbwr != null) {
nbwr.normal();
}
}
}
示例2: getRemoteURLs
import org.eclipse.aether.graph.DependencyNode; //导入依赖的package包/类
private List<URL> getRemoteURLs(final List<DependencyNode> nodes) throws IOException {
final List<URL> urls = new ArrayList<URL>();
for (DependencyNode node : nodes) {
final Artifact artifact = node.getArtifact();
boolean added = false;
for (RemoteRepository repository : node.getRepositories()) {
if (!added) {
final URL url = constructRemoteURL(artifact, repository);
added |= URLUtils.ping(url, URL_PING_TIMEOUT_MILLIS) && urls.add(url);
}
}
if (!added) { throw new IOException("unable to resolve the remote ural of artifact " + artifact); }
}
return urls;
}
示例3: visitEnter
import org.eclipse.aether.graph.DependencyNode; //导入依赖的package包/类
@Override
public boolean visitEnter(DependencyNode dependencyNode) {
if (dependencyNode == null || dependencyNode.getDependency().isOptional()) {
return false;
}
MavenJarRule rule = getRule(dependencyNode);
boolean isFirstVisit = visited.add(rule);
if (!isFirstVisit) {
return false;
}
for (DependencyNode child : dependencyNode.getChildren()) {
MavenJarRule childRule = getRule(child);
ruleGraph.putEdge(rule, childRule);
}
return true;
}
示例4: resolveArtifacts
import org.eclipse.aether.graph.DependencyNode; //导入依赖的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();
}
示例5: testBasicParentChildRelations
import org.eclipse.aether.graph.DependencyNode; //导入依赖的package包/类
/**
* Ensures that the generated rules preserve dependency relations
* (i.e. parent, child sets). This will be used to generate the deps field.
*/
@Test
public void testBasicParentChildRelations() {
DependencyNode sentinel = dependencyNode("dummy:dummy:0");
DependencyNode parentNode = dependencyNode("a:a:1");
DependencyNode childNode = dependencyNode("a:2:1");
sentinel.setChildren(ImmutableList.of(parentNode));
parentNode.setChildren(ImmutableList.of(childNode));
MavenJarRule parent = new MavenJarRule(parentNode);
MavenJarRule child = new MavenJarRule(childNode);
addDependency(parent, child);
Set<MavenJarRule> actual = GraphSerializer.generateBuildRules(sentinel);
assertRuleSetContainsExactly(actual, parent, child);
}
示例6: testMultipleDirectDependencies
import org.eclipse.aether.graph.DependencyNode; //导入依赖的package包/类
@Test
public void testMultipleDirectDependencies() {
DependencyNode sentinel = dependencyNode("dummy:dummy:0");
DependencyNode nodeA = dependencyNode("a:a:1");
DependencyNode nodeA1 = dependencyNode("a:1:1");
DependencyNode nodeB = dependencyNode("b:b:1");
DependencyNode nodeC = dependencyNode("c:c:1");
sentinel.setChildren(ImmutableList.of(nodeA, nodeB, nodeC));
nodeA.setChildren(ImmutableList.of(nodeA1));
Set<MavenJarRule> rules = GraphSerializer.generateBuildRules(sentinel);
MavenJarRule ruleA = new MavenJarRule(nodeA);
MavenJarRule ruleA1 = new MavenJarRule(nodeA1);
MavenJarRule ruleB = new MavenJarRule(nodeB);
MavenJarRule ruleC = new MavenJarRule(nodeC);
addDependency(ruleA, ruleA1);
assertRuleSetContainsExactly(rules, ruleA, ruleA1, ruleB, ruleC);
}
示例7: testSharedChild
import org.eclipse.aether.graph.DependencyNode; //导入依赖的package包/类
@Test
public void testSharedChild() {
DependencyNode sentinel = dependencyNode("dummy:dummy:0");
DependencyNode nodeA = dependencyNode("a:a:1");
DependencyNode nodeB = dependencyNode("b:b:1");
DependencyNode child = dependencyNode("child:child:1");
sentinel.setChildren(ImmutableList.of(nodeA, nodeB));
nodeA.setChildren(ImmutableList.of(child));
nodeB.setChildren(ImmutableList.of(child));
Set<MavenJarRule> rules = GraphSerializer.generateBuildRules(sentinel);
MavenJarRule ruleA = new MavenJarRule(nodeA);
MavenJarRule ruleB = new MavenJarRule(nodeB);
MavenJarRule childRule = new MavenJarRule(child);
addDependency(ruleA, childRule);
addDependency(ruleB, childRule);
assertRuleSetContainsExactly(rules, ruleA, ruleB, childRule);
}
示例8: 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);
}
示例9: 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);
}
示例10: BootClassLoader
import org.eclipse.aether.graph.DependencyNode; //导入依赖的package包/类
public BootClassLoader(ClassLoader parent, DependencyNode rootNode) throws Exception {
super(parent);
synchronized (BootClassLoader.class) {
this.id = bootClassLoaderId++;
}
this.rootNode=rootNode;
this.nodeClassLoaders = new LinkedHashMap<String, NodeClassLoader>();
this.rootNodeClassLoaders = new ArrayList<NodeClassLoader>();
NodeClassLoader nodeClassLoader=new NodeClassLoader(this, rootNode);
rootNodeClassLoaders.add(nodeClassLoader);
this.tmpLibs = new LinkedHashMap<String, File>();
this.protectionDomains = new LinkedHashMap<URL, ProtectionDomain>();
initTmpLibDir();
cacheResources();
}
示例11: getExtraDependencies
import org.eclipse.aether.graph.DependencyNode; //导入依赖的package包/类
/**
* Takes a list of dependencies and creates a list of extras (poms, javadocs and/or sources) for those dependencies.
* <p/>
* Set one or more of the following system properties to make the method return artifacts of a specified type:
* <ul>
* <li><code>swarm.download.sources</code> for sources</li>
* <li><code>swarm.download.poms</code> for pom files</li>
* <li><code>swarm.download.javadocs</code> for javadocs</li>
* </ul>
* <p/>
*
* @param nodes list of dependencies
* @return list of extra artifacts
*/
public static List<DependencyNode> getExtraDependencies(List<DependencyNode> nodes) {
ExtraArtifactsHandler fetcher = new ExtraArtifactsHandler(nodes);
if (isSet("swarm.download.sources")) {
System.out.println("will download sources");
fetcher.addWithClassifier("sources");
}
if (isSet("swarm.download.poms")) {
System.out.println("will download poms");
fetcher.addWithExtension("pom");
}
if (isSet("swarm.download.javadocs")) {
System.out.println("will download javadocs");
fetcher.addWithClassifier("javadoc");
}
return fetcher.output;
}
示例12: addDependencies
import org.eclipse.aether.graph.DependencyNode; //导入依赖的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);
}
示例13: shouldGetWithClassifierAndExtension
import org.eclipse.aether.graph.DependencyNode; //导入依赖的package包/类
private void shouldGetWithClassifierAndExtension(String classifier, String extension) {
DependencyNode dependency = dependencyNode();
List<DependencyNode> extraDependencies =
ExtraArtifactsHandler.getExtraDependencies(Collections.singletonList(dependency));
assertThat(extraDependencies).hasSize(1);
DependencyNode extraDependency = extraDependencies.get(0);
Artifact artifact = extraDependency.getDependency().getArtifact();
assertThat(artifact.getGroupId()).isEqualTo(GROUP_ID);
assertThat(artifact.getArtifactId()).isEqualTo(ARTIFACT_ID);
assertThat(artifact.getVersion()).isEqualTo(VERSION);
assertThat(artifact.getClassifier()).isEqualTo(classifier);
assertThat(artifact.getExtension()).isEqualTo(extension);
}
示例14: getAllDependencies
import org.eclipse.aether.graph.DependencyNode; //导入依赖的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();
}
示例15: getBundleDependencies
import org.eclipse.aether.graph.DependencyNode; //导入依赖的package包/类
public Set<BundleArtifact> getBundleDependencies(String... scopes)
throws MojoExecutionException {
ScopeDependencyFilter scopeFilter = new ScopeDependencyFilter(Arrays.asList(scopes), null);
DefaultDependencyResolutionRequest dependencyResolutionRequest = new DefaultDependencyResolutionRequest(
project, repositorySystemSession);
dependencyResolutionRequest.setResolutionFilter(scopeFilter);
DependencyResolutionResult dependencyResolutionResult;
try {
dependencyResolutionResult = projectDependenciesResolver
.resolve(dependencyResolutionRequest);
} catch (DependencyResolutionException ex) {
throw new MojoExecutionException(ex.getMessage(), ex);
}
DependencyNode dependencyGraph = dependencyResolutionResult.getDependencyGraph();
if (dependencyGraph != null) {
checkBundleDependencies(dependencyGraph.getChildren());
return getBundleArtifacts(dependencyGraph.getChildren());
} else {
return new HashSet<BundleArtifact>();
}
}