本文整理匯總了Java中org.eclipse.aether.collection.CollectRequest.setRepositories方法的典型用法代碼示例。如果您正苦於以下問題:Java CollectRequest.setRepositories方法的具體用法?Java CollectRequest.setRepositories怎麽用?Java CollectRequest.setRepositories使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.aether.collection.CollectRequest
的用法示例。
在下文中一共展示了CollectRequest.setRepositories方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: 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()));
}
示例3: 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;
}
示例4: getRunTimeTransitiveDeps
import org.eclipse.aether.collection.CollectRequest; //導入方法依賴的package包/類
private ImmutableMap<String, Artifact> getRunTimeTransitiveDeps(Iterable<Dependency> mavenCoords)
throws RepositoryException {
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRequestContext(JavaScopes.RUNTIME);
collectRequest.setRepositories(repos);
for (Dependency dep : mavenCoords) {
collectRequest.addDependency(dep);
}
DependencyFilter filter = DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME);
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, filter);
DependencyResult dependencyResult = repoSys.resolveDependencies(session, dependencyRequest);
ImmutableSortedMap.Builder<String, Artifact> knownDeps = ImmutableSortedMap.naturalOrder();
for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) {
Artifact node = artifactResult.getArtifact();
knownDeps.put(buildKey(node), node);
}
return knownDeps.build();
}
示例5: collectDependencies
import org.eclipse.aether.collection.CollectRequest; //導入方法依賴的package包/類
private CollectResult collectDependencies(final Artifact artifact, final List<RemoteRepository> repositories) throws DependencyCollectionException {
final CollectResult collectResult;
final CollectRequest collectRequest = new CollectRequest();
final Dependency root_dependency = new Dependency(artifact, "");
collectRequest.setRoot(root_dependency);
collectRequest.setRepositories(repositories);
collectResult = REPOSITORY_SYSTEM.collectDependencies(session, collectRequest);
return collectResult;
}
示例6: prepareDependencies
import org.eclipse.aether.collection.CollectRequest; //導入方法依賴的package包/類
/**
* Prepare an import with dependencies
* <p>
* This method does resolve even transient dependencies and also adds the
* sources if requested
* </p>
*/
public static AetherResult prepareDependencies ( final Path tmpDir, final ImportConfiguration cfg ) throws RepositoryException
{
Objects.requireNonNull ( tmpDir );
Objects.requireNonNull ( cfg );
final RepositoryContext ctx = new RepositoryContext ( tmpDir, cfg.getRepositoryUrl (), cfg.isAllOptional () );
// add all coordinates
final CollectRequest cr = new CollectRequest ();
cr.setRepositories ( ctx.getRepositories () );
for ( final MavenCoordinates coords : cfg.getCoordinates () )
{
final Dependency dep = new Dependency ( new DefaultArtifact ( coords.toString () ), COMPILE );
cr.addDependency ( dep );
}
final DependencyFilter filter = DependencyFilterUtils.classpathFilter ( COMPILE );
final DependencyRequest deps = new DependencyRequest ( cr, filter );
// resolve
final DependencyResult dr = ctx.getSystem ().resolveDependencies ( ctx.getSession (), deps );
final List<ArtifactResult> arts = dr.getArtifactResults ();
if ( !cfg.isIncludeSources () )
{
// we are already done here
return asResult ( arts, cfg, of ( dr ) );
}
// resolve sources
final List<ArtifactRequest> requests = extendRequests ( arts.stream ().map ( ArtifactResult::getRequest ), ctx, cfg );
return asResult ( resolve ( ctx, requests ), cfg, of ( dr ) );
}
示例7: configureRepositories
import org.eclipse.aether.collection.CollectRequest; //導入方法依賴的package包/類
public static void configureRepositories(CollectRequest collectRequest, RepositorySystemSession session) {
List<RemoteRepository> repositories = new ArrayList<RemoteRepository>();
for(RemoteRepository repository: collectRequest.getRepositories()){
repositories.add(applySessionSettingsToRepository(session, repository));
}
collectRequest.setRepositories(repositories);
}
示例8: buildDependencyRequest
import org.eclipse.aether.collection.CollectRequest; //導入方法依賴的package包/類
private static DependencyRequest buildDependencyRequest(List<RemoteRepository> repositories, String identifier, String scope)
{
Artifact artifact = new DefaultArtifact(identifier);
DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(scope);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, scope));
collectRequest.setRepositories(repositories);
return new DependencyRequest(collectRequest, classpathFlter);
}
示例9: resolveAll
import org.eclipse.aether.collection.CollectRequest; //導入方法依賴的package包/類
@Override
public Set<ArtifactSpec> resolveAll(Set<ArtifactSpec> specs) throws Exception {
if (specs.isEmpty()) {
return specs;
}
final CollectRequest request = new CollectRequest();
request.setRepositories(this.remoteRepositories);
specs.forEach(spec -> request
.addDependency(new Dependency(new DefaultArtifact(spec.groupId(),
spec.artifactId(),
spec.classifier(),
spec.type(),
spec.version()),
"compile")));
CollectResult result = this.system.collectDependencies(this.session, request);
PreorderNodeListGenerator gen = new PreorderNodeListGenerator();
result.getRoot().accept(gen);
return gen.getNodes().stream()
.filter(node -> !"system".equals(node.getDependency().getScope()))
.map(node -> {
final Artifact artifact = node.getArtifact();
return new ArtifactSpec(node.getDependency().getScope(),
artifact.getGroupId(),
artifact.getArtifactId(),
artifact.getVersion(),
artifact.getExtension(),
artifact.getClassifier(),
null);
})
.map(this::resolve)
.filter(x -> x != null)
.collect(Collectors.toSet());
}
開發者ID:wildfly-swarm-archive,項目名稱:ARCHIVE-wildfly-swarm,代碼行數:41,代碼來源:MavenArtifactResolvingHelper.java
示例10: resolveDependencies
import org.eclipse.aether.collection.CollectRequest; //導入方法依賴的package包/類
public DependencyResult resolveDependencies(Artifact artifact) throws DependencyCollectionException, DependencyResolutionException {
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, ""));
collectRequest.setRepositories(remotes);
DependencyRequest dependencyRequest = new DependencyRequest();
dependencyRequest.setCollectRequest(collectRequest);
return repositorySystem.resolveDependencies(repositorySystemSession, dependencyRequest);
}
示例11: resolveArtifacts
import org.eclipse.aether.collection.CollectRequest; //導入方法依賴的package包/類
public List<ArtifactResult> resolveArtifacts() throws MojoFailureException {
CollectRequest collectRequest = new CollectRequest();
final Artifact mainArtifact = new DefaultArtifact(project.getArtifact().getId());
collectRequest.setRoot(new Dependency(mainArtifact, JavaScopes.COMPILE));
collectRequest.setRepositories(projectRepos);
DependencyRequest dependencyRequest = new DependencyRequest().setCollectRequest(collectRequest);
dependencyRequest.setFilter(new DependencyFilter() {
public boolean accept(DependencyNode node,
List<DependencyNode> parents) {
Artifact nodeArtifact = node.getArtifact();
if (nodeArtifact.getGroupId().equals(mainArtifact.getGroupId()) &&
nodeArtifact.getArtifactId().equals(mainArtifact.getArtifactId())) {
return false;
}
return true;
}
});
List<ArtifactResult> resolvedArtifacts;
try {
resolvedArtifacts = repoSystem.resolveDependencies(repoSession, dependencyRequest).getArtifactResults();
} catch (DependencyResolutionException e) {
log.error("Could not resolve dependencies");
log.error(e.getMessage());
throw new MojoFailureException("Could not resolve dependencies");
}
return resolvedArtifacts;
}
示例12: execute
import org.eclipse.aether.collection.CollectRequest; //導入方法依賴的package包/類
@Override
public void execute(DependencyResolveDetails dependencyResolveDetails) {
String group = dependencyResolveDetails.getTarget().getGroup();
String name = dependencyResolveDetails.getTarget().getName();
if (aetherPlugin.getVersionMap().containsKey(group) && aetherPlugin.getVersionMap().get(group).containsKey(name)) {
if (dependencyResolveDetails.getRequested().getVersion().equals(dependencyResolveDetails.getTarget().getVersion())) {
dependencyResolveDetails.useVersion(aetherPlugin.getVersionMap().get(group).get(name));
}
} else {
RepositorySystem system = setupRepositorySystem();
RepositorySystemSession session = setupSession(project, system);
List<RemoteRepository> remoteRepositories = new ArrayList<>();
for (ArtifactRepository artifactRepository : project.getRepositories()) {
if (artifactRepository instanceof MavenArtifactRepository) {
MavenArtifactRepository mavenArtifactRepository = (MavenArtifactRepository) artifactRepository;
remoteRepositories.add(new RemoteRepository.Builder(mavenArtifactRepository.getName(), "default", mavenArtifactRepository.getUrl().toString()).build());
}
}
Artifact artifact = new DefaultArtifact(dependencyResolveDetails.getTarget().getGroup()
+ ":" + dependencyResolveDetails.getTarget().getName()
+ ":" + dependencyResolveDetails.getTarget().getVersion());
CollectRequest collectRequest = new CollectRequest();
String scope;
if (configuration.getName().contains("test")) {
scope = JavaScopes.TEST;
} else if (configuration.getName().contains("runtime")) {
scope = JavaScopes.RUNTIME;
} else if (configuration.getName().equals("providedCompile")
|| configuration.getName().equals("compileOnly")) {
scope = JavaScopes.PROVIDED;
} else
scope = JavaScopes.COMPILE;
collectRequest.setRoot(new Dependency(artifact, scope));
collectRequest.setRepositories(remoteRepositories);
try {
CollectResult collectResult = system.collectDependencies(session, collectRequest);
processDependencyNode(collectResult.getRoot());
} catch (DependencyCollectionException e) {
e.printStackTrace();
}
}
}
示例13: listTransitiveDependencies
import org.eclipse.aether.collection.CollectRequest; //導入方法依賴的package包/類
public static Set<DependencyWrapper> listTransitiveDependencies(Set<DependencyWrapper> dependencySet) {
Set<DependencyWrapper> dependencies = Sets.newHashSet();
for (DependencyWrapper dependency : dependencySet) {
RepositorySystem system = Booter.newRepositorySystem();
RepositorySystemSession session = Booter.newRepositorySystemSession(system);
Artifact artifact = new DefaultArtifact(
String.format("%s:%s:%s", dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion()));
DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
collectRequest.setRepositories(Booter.newRepositories(system, session));
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFlter);
List<ArtifactResult> artifactResults = null;
try {
artifactResults = system.resolveDependencies(session, dependencyRequest).getArtifactResults();
} catch (DependencyResolutionException e) {
continue;
}
for (ArtifactResult artifactResult : artifactResults) {
if (artifactResult.getRepository() == null) {
continue;
}
Artifact artifact1 = artifactResult.getArtifact();
org.apache.maven.model.Dependency dependency1 = new org.apache.maven.model.Dependency();
dependency1.setArtifactId(artifact1.getArtifactId());
dependency1.setGroupId(artifact1.getGroupId());
dependency1.setVersion(artifact1.getVersion());
dependency1.setClassifier(artifact1.getClassifier());
if (!MavenUtils.isDependencyResolvable(dependency1)) {
continue;
}
dependencies
.add(new DependencyWrapper(artifact1.getGroupId(), artifact1.getArtifactId(), artifact1.getVersion()));
}
}
return dependencies;
}
示例14: addDep
import org.eclipse.aether.collection.CollectRequest; //導入方法依賴的package包/類
private void addDep(String groupId, String artifactId, String classifier, String version) throws MojoExecutionException {
getLog().debug("addDep "+groupId+":"+artifactId);
org.eclipse.aether.artifact.Artifact aetherArtifact = new DefaultArtifact(
groupId,
artifactId,
classifier,
"jar",
version);
final org.eclipse.aether.graph.Dependency dependency = new org.eclipse.aether.graph.Dependency( aetherArtifact, JavaScopes.COMPILE );
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRepositories(this.repositories);
collectRequest.setRoot( dependency );
DependencyRequest dependencyRequest = new DependencyRequest();
dependencyRequest.setCollectRequest(collectRequest);
dependencyRequest.setFilter(new DependencyFilter(){
@Override
public boolean accept(DependencyNode dep, List<DependencyNode> parents) {
return dep.getArtifact().getClassifier() == null;
}
});
DependencyResult dependencyResult;
try {
dependencyResult = this.repoSystem.resolveDependencies(this.repoSession, dependencyRequest);
} catch (DependencyResolutionException e) {
throw new MojoExecutionException( "Artifact could not be resolved.", e );
}
getLog().debug("Got results: "+dependencyResult.getArtifactResults());
for(ArtifactResult result : dependencyResult.getArtifactResults()){
getLog().debug("Got result: "+result);
File file = result.getArtifact().getFile();
if( file == null || ! file.exists()) {
getLog().warn( "Artifact has no attached file. Its content will not be copied in the target model directory." );
}else if(file.isDirectory()){
getLog().warn( "Artifact is a folder. Its content will not be copied in the target model directory." );
}else{
exportDependency(result.getArtifact().getVersion(), file);
}
}
}