当前位置: 首页>>代码示例>>Java>>正文


Java CollectRequest.setRepositories方法代码示例

本文整理汇总了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;
}
 
开发者ID:microsofia,项目名称:microsofia-boot,代码行数:24,代码来源:DependencyResolver.java

示例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()));
  }
 
开发者ID:pgr0ss,项目名称:bazel-deps,代码行数:27,代码来源:Maven.java

示例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;
}
 
开发者ID:vert-x3,项目名称:vertx-maven-service-factory,代码行数:17,代码来源:AetherHelper.java

示例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();
}
 
开发者ID:facebook,项目名称:buck,代码行数:24,代码来源:Resolver.java

示例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;
    }
 
开发者ID:stacs-srg,项目名称:shabdiz,代码行数:11,代码来源:MavenDependencyResolver.java

示例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 ) );
}
 
开发者ID:eclipse,项目名称:packagedrone,代码行数:45,代码来源:AetherImporter.java

示例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);
}
 
开发者ID:igor-suhorukov,项目名称:mvn-classloader,代码行数:8,代码来源:RepositoryUtils.java

示例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);
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:13,代码来源:RemotePluginLoader.java

示例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);
}
 
开发者ID:gsson,项目名称:dependency-grapher,代码行数:12,代码来源:Resolver.java

示例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;
}
 
开发者ID:mestevens,项目名称:unity-maven-plugin,代码行数:32,代码来源:DependencyGatherer.java

示例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();
        }
    }
}
 
开发者ID:SetoKaiba,项目名称:aether-gradle-plugin,代码行数:45,代码来源:VersionResolverDependencyResolveDetails.java

示例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;
}
 
开发者ID:AGETO,项目名称:hybris-maven-plugin,代码行数:51,代码来源:DependencyResolver.java

示例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);
		}
	}
}
 
开发者ID:ceylon,项目名称:ceylon-maven-plugin,代码行数:44,代码来源:AbstractCeylonMojo.java


注:本文中的org.eclipse.aether.collection.CollectRequest.setRepositories方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。