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


Java CollectRequest类代码示例

本文整理汇总了Java中org.sonatype.aether.collection.CollectRequest的典型用法代码示例。如果您正苦于以下问题:Java CollectRequest类的具体用法?Java CollectRequest怎么用?Java CollectRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CollectRequest类属于org.sonatype.aether.collection包,在下文中一共展示了CollectRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getArtifactsWithDep

import org.sonatype.aether.collection.CollectRequest; //导入依赖的package包/类
/**
 *
 * @param dependency
 * @param excludes list of pattern can either be of the form groupId:artifactId
 * @return
 * @throws Exception
 */
public List<ArtifactResult> getArtifactsWithDep(String dependency,
    Collection<String> excludes) throws Exception {
  Artifact artifact = new DefaultArtifact(inferScalaVersion(dependency));
  DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter( JavaScopes.COMPILE );
  PatternExclusionsDependencyFilter exclusionFilter =
      new PatternExclusionsDependencyFilter(inferScalaVersion(excludes));

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));

  synchronized (repos) {
    for (RemoteRepository repo : repos) {
      collectRequest.addRepository(repo);
    }
  }
  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
      DependencyFilterUtils.andFilter(exclusionFilter, classpathFlter));
  return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:27,代码来源:DependencyResolver.java

示例2: fetchArtifactWithDep

import org.sonatype.aether.collection.CollectRequest; //导入依赖的package包/类
private List<ArtifactResult> fetchArtifactWithDep(Dependency dep)
    throws DependencyResolutionException, ArtifactResolutionException {
  Artifact artifact = new DefaultArtifact(dep.getGroupArtifactVersion());

  DependencyFilter classpathFilter = DependencyFilterUtils
      .classpathFilter(JavaScopes.COMPILE);
  PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(
      dep.getExclusions());

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new org.sonatype.aether.graph.Dependency(artifact,
      JavaScopes.COMPILE));

  collectRequest.addRepository(mavenCentral);
  collectRequest.addRepository(mavenLocal);
  for (Repository repo : repositories) {
    RemoteRepository rr = new RemoteRepository(repo.getId(), "default", repo.getUrl());
    rr.setPolicy(repo.isSnapshot(), null);
    collectRequest.addRepository(rr);
  }

  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
      DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));

  return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:27,代码来源:DependencyContext.java

示例3: getArtifactsWithDep

import org.sonatype.aether.collection.CollectRequest; //导入依赖的package包/类
/**
 * @param dependency
 * @param excludes list of pattern can either be of the form groupId:artifactId
 * @return
 * @throws Exception
 */
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency,
  Collection<String> excludes) throws RepositoryException {
  Artifact artifact = new DefaultArtifact(dependency);
  DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
  PatternExclusionsDependencyFilter exclusionFilter =
          new PatternExclusionsDependencyFilter(excludes);

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));

  synchronized (repos) {
    for (RemoteRepository repo : repos) {
      collectRequest.addRepository(repo);
    }
  }
  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
          DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
  try {
    return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
  } catch (NullPointerException | DependencyResolutionException ex) {
    throw new RepositoryException(
            String.format("Cannot fetch dependencies for %s", dependency), ex);
  }
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:32,代码来源:DependencyResolver.java

示例4: getArtifactsWithDep

import org.sonatype.aether.collection.CollectRequest; //导入依赖的package包/类
/**
 * @param dependency
 * @param excludes list of pattern can either be of the form groupId:artifactId
 * @return
 * @throws Exception
 */
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency,
    Collection<String> excludes) throws Exception {
  Artifact artifact = new DefaultArtifact(inferScalaVersion(dependency));
  DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
  PatternExclusionsDependencyFilter exclusionFilter =
      new PatternExclusionsDependencyFilter(inferScalaVersion(excludes));

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));

  synchronized (repos) {
    for (RemoteRepository repo : repos) {
      collectRequest.addRepository(repo);
    }
  }
  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
      DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
  return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:27,代码来源:SparkDependencyResolver.java

示例5: testCollectDependencies

import org.sonatype.aether.collection.CollectRequest; //导入依赖的package包/类
public void testCollectDependencies()
    throws Exception
{
    Artifact artifact = new DefaultArtifact( "ut.simple:artifact:extension:classifier:1.0" );
    // notice: extension and classifier not really used in this test...

    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot( new Dependency( artifact, null ) );
    collectRequest.addRepository( newTestRepository() );

    CollectResult collectResult = system.collectDependencies( session, collectRequest );

    List<DependencyNode> nodes = collectResult.getRoot().getChildren();
    assertEquals( 2, nodes.size() );
    checkUtSimpleArtifactDependencies( nodes.get( 0 ).getDependency(), nodes.get( 1 ).getDependency() );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:17,代码来源:RepositorySystemTest.java

示例6: resolve

import org.sonatype.aether.collection.CollectRequest; //导入依赖的package包/类
private void resolve( ResolveRequest resolveRequest )
{

    RepositorySystem system = newRepositorySystem();

    RepositorySystemSession session = newRepositorySystemSession( system, resolveRequest.localRepoDir );

    org.sonatype.aether.artifact.Artifact artifact = new DefaultArtifact(
        resolveRequest.groupId + ":" + resolveRequest.artifactId + ":" + resolveRequest.version );

    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot( new Dependency( artifact, "" ) );

    // add remote repositories
    for ( RemoteRepository remoteRepository : resolveRequest.remoteRepositories )
    {
        collectRequest.addRepository(
            new org.sonatype.aether.repository.RemoteRepository( remoteRepository.getId(), "default",
                                                                 remoteRepository.getUrl() ) );
    }
    collectRequest.setRequestContext( "project" );

    //collectRequest.addRepository( repo );

    try
    {
        CollectResult collectResult = system.collectDependencies( session, collectRequest );
        collectResult.getRoot().accept( resolveRequest.dependencyVisitor );
        log.debug( "test" );
    }
    catch ( DependencyCollectionException e )
    {
        log.error( e.getMessage(), e );
    }


}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:38,代码来源:Maven3DependencyTreeBuilder.java

示例7: createCollectRequestForGAV

import org.sonatype.aether.collection.CollectRequest; //导入依赖的package包/类
private CollectRequest createCollectRequestForGAV(String gav) {
  DefaultArtifact artifact = new DefaultArtifact(gav);
  Dependency dependency = new Dependency(artifact, COMPILE_SCOPE);

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(dependency);
  for (RemoteRepository repository : repositories) {
    collectRequest.addRepository(repository);
  }

  return collectRequest;
}
 
开发者ID:zulily,项目名称:dropship,代码行数:13,代码来源:MavenArtifactResolution.java

示例8: resolveArtifacts

import org.sonatype.aether.collection.CollectRequest; //导入依赖的package包/类
public List<Artifact> resolveArtifacts(Iterable<? extends Artifact> sourceArtifacts)
{
    CollectRequest collectRequest = new CollectRequest();
    for (Artifact sourceArtifact : sourceArtifacts) {
        collectRequest.addDependency(new Dependency(sourceArtifact, JavaScopes.RUNTIME));
    }
    for (RemoteRepository repository : repositories) {
        collectRequest.addRepository(repository);
    }

    DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME));

    return resolveArtifacts(dependencyRequest);
}
 
开发者ID:airlift,项目名称:resolver,代码行数:15,代码来源:ArtifactResolver.java

示例9: resolveDependencies

import org.sonatype.aether.collection.CollectRequest; //导入依赖的package包/类
/**
 * Resolves dependencies transitively from the given jar artifact, with the specified Maven scope
 * (compile, runtime, and so on.)
 */
public DependencyResult resolveDependencies(GAV a, String scope) throws DependencyResolutionException {
    DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(scope);

    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot(new Dependency(new DefaultArtifact(a.toString()), JavaScopes.COMPILE));
    collectRequest.setRepositories(remoteRepositories);

    DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFlter);

    return resolveDependencies(dependencyRequest);
}
 
开发者ID:cloudbees,项目名称:bees-maven-components,代码行数:16,代码来源:RepositoryService.java

示例10: downloadArtifacts

import org.sonatype.aether.collection.CollectRequest; //导入依赖的package包/类
@SuppressWarnings("ConstantConditions")
private void downloadArtifacts(CollectRequest request)
  throws VersionRangeResolutionException, ArtifactNotFoundException {
  try {
    logger.info("Resolving dependencies");
    List<Artifact> artifacts = collectDependenciesIntoArtifacts(request);

    final File downloadDir = new File(settings.localDownloadPath());

    if (!downloadDir.exists() && !downloadDir.mkdirs()) {
      throw new DropshipRuntimeException("Could not create the local download directory " + settings.localDownloadPath());
    }

    for (Artifact artifact : artifacts) {
      logger.info("Copying " + artifact.getFile().getName() + " to " + settings.localDownloadPath());
      copy(artifact.getFile(), new File(downloadDir, artifact.getFile().getName()));
    }

  } catch (Exception e) {
    Throwable rootCause = e;
    while (rootCause.getCause() != null) {
      rootCause = rootCause.getCause();
    }
    if (rootCause instanceof VersionRangeResolutionException) {
      throw ((VersionRangeResolutionException) rootCause);
    }
    if (rootCause instanceof ArtifactNotFoundException) {
      throw ((ArtifactNotFoundException) rootCause);
    }
    if (e instanceof SecurityException) {
      throw ((SecurityException) e);
    }
    if (e instanceof DropshipRuntimeException) {
      throw ((DropshipRuntimeException) e);
    }
    if (e instanceof RuntimeException) {
      throw ((RuntimeException) e);
    }
    throw new RuntimeException(e);
  }
}
 
开发者ID:zulily,项目名称:dropship,代码行数:42,代码来源:MavenArtifactResolution.java

示例11: createClassLoader

import org.sonatype.aether.collection.CollectRequest; //导入依赖的package包/类
@SuppressWarnings("ConstantConditions")
private URLClassLoader createClassLoader(String groupArtifactVersion, CollectRequest request)
  throws VersionRangeResolutionException, ArtifactNotFoundException {

  try {
    logger.info("Resolving dependencies");
    List<Artifact> artifacts = collectDependenciesIntoArtifacts(request);

    logger.info("Building classpath for %s from %d URLs", groupArtifactVersion, artifacts.size());
    List<URL> urls = new ArrayList<URL>();
    for (Artifact artifact : artifacts) {
      urls.add(artifact.getFile().toURI().toURL());
    }

    for (String path : settings.additionalClasspathPaths()) {
      logger.info("Adding \"%s\" to classpath", path);
      urls.add(new File(path).toURI().toURL());
    }

    return new URLClassLoader(urls.toArray(new URL[urls.size()]), SHARE_NOTHING);
  } catch (Exception e) {
    Throwable rootCause = e;
    while (rootCause.getCause() != null) {
      rootCause = rootCause.getCause();
    }
    if (rootCause instanceof VersionRangeResolutionException) {
      throw ((VersionRangeResolutionException) rootCause);
    }
    if (rootCause instanceof ArtifactNotFoundException) {
      throw ((ArtifactNotFoundException) rootCause);
    }
    if (e instanceof SecurityException) {
      throw ((SecurityException) e);
    }
    if (e instanceof DropshipRuntimeException) {
      throw ((DropshipRuntimeException) e);
    }
    if (e instanceof RuntimeException) {
      throw ((RuntimeException) e);
    }
    throw new RuntimeException(e);
  }
}
 
开发者ID:zulily,项目名称:dropship,代码行数:44,代码来源:MavenArtifactResolution.java

示例12: collectDependenciesIntoArtifacts

import org.sonatype.aether.collection.CollectRequest; //导入依赖的package包/类
private List<Artifact> collectDependenciesIntoArtifacts(CollectRequest collectRequest)
  throws PlexusContainerException, ComponentLookupException, DependencyCollectionException, ArtifactResolutionException, DependencyResolutionException {

  RepositorySystem repositorySystem = newRepositorySystem();
  RepositorySystemSession session = newSession(repositorySystem);
  DependencyNode node = repositorySystem.collectDependencies(session, collectRequest).getRoot();

  DependencyFilter filter = new ScopeDependencyFilter();

  DependencyRequest request = new DependencyRequest(node, filter);

  repositorySystem.resolveDependencies(session, request);

  // PathRecordingDependencyVisitor will give every path, which may help in building a hierarchical class loader
  PreorderNodeListGenerator nlg = new PreorderNodeListGenerator();
  node.accept(nlg);

  return nlg.getArtifacts(false);
}
 
开发者ID:zulily,项目名称:dropship,代码行数:20,代码来源:MavenArtifactResolution.java

示例13: main

import org.sonatype.aether.collection.CollectRequest; //导入依赖的package包/类
public static void main( String[] args )
		throws Exception
		{
	System.out.println( "------------------------------------------------------------" );
	System.out.println( ResolveTest.class.getSimpleName() );

	RepositorySystem system = Maven.repositorySystem();

	RepositorySystemSession session = Maven.repositorySystemSession(system);

	Artifact artifact = new DefaultArtifact( "org.springframework:spring-orm:2.5.6" );
	Artifact artifact2 = new DefaultArtifact("org.springframework:spring-webmvc:3.2.2.RELEASE");

	RemoteRepository repo = Maven.central();

	DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter( JavaScopes.COMPILE );

	CollectRequest collectRequest = new CollectRequest();
	//collectRequest.setRoot( new Dependency( artifact, JavaScopes.COMPILE ) );
	collectRequest.addDependency(new Dependency(artifact, JavaScopes.COMPILE));
	collectRequest.addDependency(new Dependency(artifact2, JavaScopes.COMPILE));
	collectRequest.addRepository( repo );

	DependencyRequest dependencyRequest = new DependencyRequest( collectRequest, classpathFlter );

	DependencyResult result = system.resolveDependencies( session, dependencyRequest );
	//List<ArtifactResult> artifactResults = result.getArtifactResults();
	//System.out.println(result.getRoot().getClass());
	//System.out.println(result.getRoot().getDependency());
	//result.getRoot().accept(new TreePrinter());

	//PreorderNodeListGenerator nlg = new PreorderNodeListGenerator();
	//result.getRoot().accept(nlg);
	//System.out.println(nlg.getArtifacts(false));
	
	//for ( ArtifactResult artifactResult : artifactResults )
	//{
	//	System.out.println( artifactResult.getArtifact() + " resolved to " + artifactResult.getArtifact().getFile() );
	//}
	
	//new NearestVersionConflictResolver().transformGraph(result.getRoot(), new MyDependencyGraphTransformationContext(session)).accept(new TreePrinter());
	
	new VersionResolver().resolve(result.getRoot());
}
 
开发者ID:bnavetta,项目名称:tycho-gen,代码行数:45,代码来源:ResolveTest.java

示例14: getClasspathFromMavenProject

import org.sonatype.aether.collection.CollectRequest; //导入依赖的package包/类
public static List<String> getClasspathFromMavenProject(File projectPom, File localRepoFolder, boolean isRunwayEnvironment) throws DependencyResolutionException, IOException, XmlPullParserException
{
  MavenProject proj = loadProject(projectPom);
  
  PropertyReplacer propReplacer = new PropertyReplacer(proj);
  
  List<Repository> repos = proj.getRepositories();
  
  List<String> classpath = new ArrayList<String>();
  
  RepositorySystem system = Booter.newRepositorySystem();
  RepositorySystemSession session = Booter.newRepositorySystemSession( system, localRepoFolder );
  RemoteRepository centralRepo = Booter.newCentralRepository();
  DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter( JavaScopes.COMPILE );
  
  List<org.apache.maven.model.Dependency> dependencies = proj.getDependencies();
  Iterator<org.apache.maven.model.Dependency> it = dependencies.iterator();
  
  while (it.hasNext()) {
    org.apache.maven.model.Dependency depend = it.next();
    
    Artifact artifact = new DefaultArtifact(propReplacer.replace(depend.getGroupId()), propReplacer.replace(depend.getArtifactId()), propReplacer.replace(depend.getClassifier()), propReplacer.replace(depend.getType()), propReplacer.replace(depend.getVersion()));

    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot( new Dependency( artifact, JavaScopes.COMPILE ) );
    collectRequest.addRepository( centralRepo );
    
    for (Repository repo : repos) {
      collectRequest.addRepository(new RemoteRepository(propReplacer.replace(repo.getId()), propReplacer.replace(repo.getLayout()), propReplacer.replace(repo.getUrl())));
    }
    
    try {
      DependencyRequest dependencyRequest = new DependencyRequest( collectRequest, classpathFlter );

      List<ArtifactResult> artifactResults =
          system.resolveDependencies( session, dependencyRequest ).getArtifactResults();

      for ( ArtifactResult artifactResult : artifactResults )
      {
        Artifact art = artifactResult.getArtifact();
        
        if (isRunwayEnvironment && art.getGroupId().equals("com.runwaysdk") && (
              art.getArtifactId().equals("runwaysdk-client") ||
              art.getArtifactId().equals("runwaysdk-common") ||
              art.getArtifactId().equals("runwaysdk-server")
            )) {
          continue;
        }
        
        classpath.add(art.getFile().getAbsolutePath());
      }
    }
    catch (DependencyResolutionException e) {
      // Is Maven ignoring this? I'm confused.
      log.error(e);
      e.printStackTrace();
    }
  }
  
  if (log.isTraceEnabled()) {
    String cpath = "";
    for (Iterator<String> i = classpath.iterator(); i.hasNext();) {
      cpath = cpath + ", " + i.next();
    }
    
    log.trace("Resolved pom [" + projectPom.getAbsolutePath() + "] classpath to [" + cpath + "]");
  }
  
  return classpath;
}
 
开发者ID:terraframe,项目名称:Runway-SDK,代码行数:71,代码来源:MavenClasspathBuilder.java

示例15: collectDependencies

import org.sonatype.aether.collection.CollectRequest; //导入依赖的package包/类
/**
 * Collects the transitive dependencies of an artifact and builds a dependency graph. Note that this operation is
 * only concerned about determining the coordinates of the transitive dependencies. To also resolve the actual
 * artifact files, use {@link #resolveDependencies(DependencyRequest)}.
 *
 * @param request The collection request, must not be {@code null}
 * @return The collection result, never {@code null}.
 * @throws org.sonatype.aether.collection.DependencyCollectionException If the dependency tree could not be built.
 * @see RepositorySystemSession#getDependencyTraverser()
 * @see RepositorySystemSession#getDependencyManager()
 * @see RepositorySystemSession#getDependencySelector()
 * @see RepositorySystemSession#getDependencyGraphTransformer()
 */
public CollectResult collectDependencies( CollectRequest request ) throws DependencyCollectionException {
    return repository.collectDependencies(session, request);
}
 
开发者ID:cloudbees,项目名称:bees-maven-components,代码行数:17,代码来源:RepositoryService.java


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