本文整理汇总了Java中org.eclipse.aether.collection.CollectRequest类的典型用法代码示例。如果您正苦于以下问题:Java CollectRequest类的具体用法?Java CollectRequest怎么用?Java CollectRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CollectRequest类属于org.eclipse.aether.collection包,在下文中一共展示了CollectRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collectDependencies
import org.eclipse.aether.collection.CollectRequest; //导入依赖的package包/类
@Override
public CollectResult collectDependencies(RepositorySystemSession session, CollectRequest request) throws DependencyCollectionException {
DefaultRepositorySystemSession cloned = new DefaultRepositorySystemSession(session);
DependencyGraphTransformer transformer = session.getDependencyGraphTransformer();
//need to reset the transformer to prevent the transformation to happen and to it below separately.
cloned.setDependencyGraphTransformer(null);
CollectResult res = super.collectDependencies(cloned, request);
CloningDependencyVisitor vis = new CloningDependencyVisitor();
res.getRoot().accept(vis);
//this part copied from DefaultDependencyCollector
try {
DefaultDependencyGraphTransformationContext context =
new DefaultDependencyGraphTransformationContext(session);
res.setRoot(transformer.transformGraph(res.getRoot(), context));
} catch (RepositoryException e) {
res.addException(e);
}
if (!res.getExceptions().isEmpty()) {
throw new DependencyCollectionException(res);
}
res.getRoot().setData("NB_TEST", vis.getRootNode());
return res;
}
示例2: resolveArtifacts
import org.eclipse.aether.collection.CollectRequest; //导入依赖的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();
}
示例3: resolveArtifacts
import org.eclipse.aether.collection.CollectRequest; //导入依赖的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);
}
}
示例4: collectDependencyArtifacts
import org.eclipse.aether.collection.CollectRequest; //导入依赖的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);
}
示例5: resolve
import org.eclipse.aether.collection.CollectRequest; //导入依赖的package包/类
private List<File> resolve(List<Dependency> dependencies)
throws ArtifactResolutionException {
try {
CollectRequest collectRequest = getCollectRequest(dependencies);
DependencyRequest dependencyRequest = getDependencyRequest(collectRequest);
DependencyResult result = this.repositorySystem
.resolveDependencies(this.session, dependencyRequest);
addManagedDependencies(result);
return getFiles(result);
}
catch (Exception ex) {
throw new DependencyResolutionFailedException(ex);
}
finally {
this.progressReporter.finished();
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:AetherGrapeEngine.java
示例6: resolve
import org.eclipse.aether.collection.CollectRequest; //导入依赖的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;
}
示例7: getAllDependencies
import org.eclipse.aether.collection.CollectRequest; //导入依赖的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();
}
示例8: getArtifactUrlsCollection
import org.eclipse.aether.collection.CollectRequest; //导入依赖的package包/类
public List<URL> getArtifactUrlsCollection(String groupArtifactVersion, Collection<String> excludes) throws Exception {
info("Collecting maven metadata.");
CollectRequest collectRequest = createCollectRequestForGAV(groupArtifactVersion);
info("Resolving dependencies.");
List<Artifact> artifacts = collectDependenciesIntoArtifacts(collectRequest, excludes);
info("Building classpath for %s from %d URLs.", groupArtifactVersion, artifacts.size());
List<URL> urls = Lists.newArrayListWithExpectedSize(artifacts.size());
for (Artifact artifact : artifacts) {
urls.add(artifact.getFile().toURI().toURL());
}
for (String path : Settings.additionalClasspathPaths()) {
info("Adding \"%s\" to classpath.", path);
urls.add(new File(path).toURI().toURL());
}
return urls;
}
示例9: resolveDependencies
import org.eclipse.aether.collection.CollectRequest; //导入依赖的package包/类
private List<Artifact> resolveDependencies(final Artifact artifact) throws DependencyResolutionException {
List<Artifact> result = new ArrayList<Artifact>();
RepositorySystem system = newRepositorySystem();
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new org.eclipse.aether.graph.Dependency(artifact, JavaScopes.COMPILE));
List<ArtifactResult> dependenciesTree = system.resolveDependencies(
session,
new DependencyRequest(collectRequest, DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE))
).getArtifactResults();
for (final ArtifactResult res : dependenciesTree) {
result.add(res.getArtifact());
}
return result;
}
示例10: transitiveDependencies
import org.eclipse.aether.collection.CollectRequest; //导入依赖的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()));
}
示例11: getDependencies
import org.eclipse.aether.collection.CollectRequest; //导入依赖的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;
}
示例12: resolveArtifactsAndDependencies
import org.eclipse.aether.collection.CollectRequest; //导入依赖的package包/类
public List<File> resolveArtifactsAndDependencies(List<Artifact> artifacts) throws ArtifactResolutionException, DependencyResolutionException {
List<Dependency> dependencies = new ArrayList<Dependency>();
for (Artifact artifact : artifacts) {
dependencies.add(new Dependency(artifact, JavaScopes.RUNTIME));
}
CollectRequest collectRequest = new CollectRequest((Dependency)null, dependencies, repositories);
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME);
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFilter);
DependencyResult result = system.resolveDependencies(session, dependencyRequest);
List<File> files = new ArrayList<File>();
for (ArtifactResult artifactResult : result.getArtifactResults()) {
files.add(artifactResult.getArtifact().getFile());
}
return files;
}
示例13: copyDependencies
import org.eclipse.aether.collection.CollectRequest; //导入依赖的package包/类
private Set<String> copyDependencies(File destination) throws DependencyResolutionException, IOException {
Set<String> artifactNames = new HashSet<String>();
for (Dependency dependency : project.getDependencies()) {
if (!excludedScopes().contains(dependency.getScope())) {
String depString = dependency.getGroupId() + ":" + dependency.getArtifactId()
+ ":" + dependency.getVersion();
CollectRequest request = new CollectRequest(
new org.eclipse.aether.graph.Dependency(
new DefaultArtifact(depString), dependency.getScope()), projectRepos);
DependencyResult result = repoSystem.resolveDependencies(
repoSession,
new DependencyRequest(request, new ScopeDependencyFilter(null, excludedScopes())));
for (ArtifactResult artifactResult : result.getArtifactResults()) {
File artifactFile = artifactResult.getArtifact().getFile();
File codeFile = new File(destination, artifactFile.getName());
FileUtils.copyFile(artifactFile, codeFile);
artifactNames.add(artifactFile.getName());
}
}
}
return artifactNames;
}
示例14: setUp
import org.eclipse.aether.collection.CollectRequest; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
classLoaderResolver = new ClassLoaderResolver(log, repositorySystem, repositorySystemSession, Collections.<RemoteRepository>emptyList());
when(repositorySystem.collectDependencies(eq(repositorySystemSession), any(CollectRequest.class)))
.thenReturn(new CollectResult(new CollectRequest()).setRoot(root));
when(child.getDependency()).thenReturn(new Dependency(new DefaultArtifact(FOO,
BAR,
QUX,
BAZ,
FOO + BAR,
Collections.<String, String>emptyMap(),
new File(FOO + "/" + BAR)), QUX + BAZ));
when(root.accept(any(DependencyVisitor.class))).then(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
DependencyVisitor dependencyVisitor = invocationOnMock.getArgument(0);
dependencyVisitor.visitEnter(child);
dependencyVisitor.visitLeave(child);
return null;
}
});
}
示例15: getArtifacts
import org.eclipse.aether.collection.CollectRequest; //导入依赖的package包/类
public List<Artifact> getArtifacts(DependencyFilter transitiveFilter)
throws DependencyCollectionException, DependencyResolutionException {
CollectRequest request = new CollectRequest(dependency, remoteRepos);
DependencyRequest dependencyRequest = new DependencyRequest(request,
transitiveFilter);
DependencyResult dependencyResult = repoSystem.resolveDependencies(
repoSession, dependencyRequest);
List<ArtifactResult> artifactResults = dependencyResult
.getArtifactResults();
List<Artifact> artifacts = new ArrayList<Artifact>();
for (ArtifactResult artifactResult : artifactResults) {
Artifact artifact = artifactResult.getArtifact();
artifacts.add(artifact);
}
return artifacts;
}