本文整理匯總了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;
}