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


Java DefaultRepositorySystemSession.setDependencySelector方法代码示例

本文整理汇总了Java中org.eclipse.aether.DefaultRepositorySystemSession.setDependencySelector方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultRepositorySystemSession.setDependencySelector方法的具体用法?Java DefaultRepositorySystemSession.setDependencySelector怎么用?Java DefaultRepositorySystemSession.setDependencySelector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.aether.DefaultRepositorySystemSession的用法示例。


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

示例1: getDependencyTree

import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
private DependencyNode getDependencyTree(Artifact artifact) throws MojoExecutionException {
    try {
        CollectRequest collectRequest = new CollectRequest(new Dependency(artifact, "compile"), null, projectRepositories);
        DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(repositorySystemSession);
        session.setDependencySelector(new AndDependencySelector(new OptionalDependencySelector(),
                new ScopeDependencySelector1(),
                new ExclusionDependencySelector()));
        // between aether-util 0.9.0.M1 and M2, JavaEffectiveScopeCalculator was removed
        // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=397241
        DependencyGraphTransformer transformer = new ChainedDependencyGraphTransformer(new ConflictMarker(),
                new ConflictResolver(new NearestVersionSelector(), new JavaScopeSelector(), new SimpleOptionalitySelector(), new JavaScopeDeriver()),
                new JavaDependencyContextRefiner());
        session.setDependencyGraphTransformer(transformer);
        CollectResult result = repositorySystem.collectDependencies(session, collectRequest);
        return result.getRoot();
    } catch (DependencyCollectionException e) {
        throw new MojoExecutionException("Cannot build project dependency tree", e);
    }
}
 
开发者ID:retog,项目名称:karaf-maven-plugin,代码行数:20,代码来源:Dependency31Helper.java

示例2: newSession

import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
/**
 * Set up repository session for maven.
 * 
 * @param system
 *          the repository system
 * @param localDownloadDir
 *          the directory where to put the downloaded artifacts
 * @return the configured repository session
 */
private RepositorySystemSession newSession(RepositorySystem system, final String localDownloadDir) {
  DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();

  LocalRepository localRepo = new LocalRepository(localDownloadDir);
  session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));

  DependencySelector depFilter =
      new AndDependencySelector(
      new ScopeDependencySelector(JavaScopes.PROVIDED),
      new OptionalDependencySelector(),
      new ExclusionDependencySelector()
  );
  session.setDependencySelector(depFilter);

  return session;
}
 
开发者ID:Gemba,项目名称:mvn-dd,代码行数:26,代码来源:RepositorySystemHelper.java

示例3: traverseAddonGraph

import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
private DependencyNode traverseAddonGraph(String coords, RepositorySystem system, Settings settings,
         DefaultRepositorySystemSession session)
{
   session.setDependencyTraverser(new AddonDependencyTraverser(this.classifier));
   session.setDependencySelector(new AddonDependencySelector(this.classifier));
   Artifact queryArtifact = new DefaultArtifact(coords);

   List<RemoteRepository> repositories = MavenRepositories.getRemoteRepositories(container, settings);
   CollectRequest collectRequest = new CollectRequest(new Dependency(queryArtifact, null), repositories);

   CollectResult result;
   try
   {
      result = system.collectDependencies(session, collectRequest);
   }
   catch (DependencyCollectionException e)
   {
      throw new RuntimeException(e);
   }
   return result.getRoot();
}
 
开发者ID:koentsje,项目名称:forge-furnace,代码行数:22,代码来源:MavenAddonDependencyResolver.java

示例4: fetchDependencyResult

import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
public DependencyResult fetchDependencyResult(DependencyNode root, DependencySelector dependencySelector)
		throws DependencyResolutionException {
	DependencyRequest dependencyRequest = this.maven.newDependencyRequest(root);
	DefaultRepositorySystemSession repositorySystemSession = this.maven.newRepositorySystemSession();
	repositorySystemSession.setDependencySelector(dependencySelector);
	return this.maven.getRepositorySystem().resolveDependencies(repositorySystemSession, dependencyRequest);
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:8,代码来源:Dependency.java

示例5: createDefaultSession

import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
public static DefaultRepositorySystemSession createDefaultSession() {
    DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
    session.setSystemProperties(System.getProperties());
    session.setDependencySelector(new AndDependencySelector(
            DeepOptionalDependencySelector.INSTANCE,
            CompileScopeDependencySelector.INSTANCE
    ));
    return session;
}
 
开发者ID:MCCityVille,项目名称:libmanager,代码行数:10,代码来源:SessionUtils.java

示例6: convertGavs

import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
private static ArchivesAndSupplementaryArchives convertGavs(String[] gavs, String errorMessagePrefix,
        File localRepo) {
    RepositorySystem repositorySystem = MavenBootstrap.newRepositorySystem();
    DefaultRepositorySystemSession session = MavenBootstrap.newRepositorySystemSession(repositorySystem, localRepo);

    session.setDependencySelector(new ScopeDependencySelector("compile", "provided"));
    session.setDependencyTraverser(new ScopeDependencyTraverser("compile", "provided"));

    RemoteRepository mavenCentral = new RemoteRepository.Builder("@@[email protected]@", "default",
            "http://repo.maven.apache.org/maven2/").build();

    List<RemoteRepository> remoteRepositories = singletonList(mavenCentral);

    ArtifactResolver resolver = new ArtifactResolver(repositorySystem, session, remoteRepositories);

    List<FileArchive> archives = new ArrayList<>();
    List<FileArchive> supplementaryArchives = new ArrayList<>();

    for (String gav : gavs) {
        try {
            archives.add(new FileArchive(resolver.resolveArtifact(gav).getFile()));
            ArtifactResolver.CollectionResult res = resolver.collectTransitiveDeps(gav);

            res.getResolvedArtifacts().
                    forEach(a -> supplementaryArchives.add(new FileArchive(a.getFile())));
            if (!res.getFailures().isEmpty()) {
                LOG.warn("Failed to resolve some transitive dependencies: " + res.getFailures().toString());
            }
        } catch (RepositoryException e) {
            throw new IllegalArgumentException(errorMessagePrefix + " " + e.getMessage());
        }
    }

    return new ArchivesAndSupplementaryArchives(archives, supplementaryArchives);
}
 
开发者ID:revapi,项目名称:revapi,代码行数:36,代码来源:Main.java

示例7: resolveResources

import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
@Override
public Response<File[]> resolveResources(final AddonId addonId)
{
   RepositorySystem system = container.getRepositorySystem();
   Settings settings = getSettings();
   DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);
   final String mavenCoords = toMavenCoords(addonId);
   Artifact queryArtifact = new DefaultArtifact(mavenCoords);
   session.setDependencyTraverser(new AddonDependencyTraverser(classifier));
   session.setDependencySelector(new AddonDependencySelector(classifier));
   Dependency dependency = new Dependency(queryArtifact, null);

   List<RemoteRepository> repositories = MavenRepositories.getRemoteRepositories(container, settings);

   CollectRequest collectRequest = new CollectRequest(dependency, repositories);
   DependencyResult result;
   try
   {
      result = system.resolveDependencies(session, new DependencyRequest(collectRequest, null));
   }
   catch (DependencyResolutionException e)
   {
      throw new RuntimeException(e);
   }
   List<Exception> collectExceptions = result.getCollectExceptions();
   Set<File> files = new HashSet<File>();
   List<ArtifactResult> artifactResults = result.getArtifactResults();
   for (ArtifactResult artifactResult : artifactResults)
   {
      Artifact artifact = artifactResult.getArtifact();
      if (isFurnaceAPI(artifact) ||
               (this.classifier.equals(artifact.getClassifier())
                        && !addonId.getName().equals(artifact.getGroupId() + ":" + artifact.getArtifactId())))
      {
         continue;
      }
      files.add(artifact.getFile());
   }
   return new MavenResponseBuilder<File[]>(files.toArray(new File[files.size()])).setExceptions(collectExceptions);
}
 
开发者ID:forge,项目名称:furnace,代码行数:41,代码来源:MavenAddonDependencyResolver.java

示例8: repositorySystemSession

import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
@Bean
public RepositorySystemSession repositorySystemSession(RepositorySystem repositorySystem) {
    // see MavenRepositorySystemUtils.newSession()

    DependencySelector selector = new AndDependencySelector(
            new ScopeDependencySelector("test", "provided"),
            new DepthOneOptionalDependencySelector(),
            new ExclusionDependencySelector());

    DependencyGraphTransformer transformer = new ConflictResolver(
            new NearestVersionSelector(),
            new JavaScopeSelector(),
            new SimpleOptionalitySelector(),
            new JavaScopeDeriver());

    DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
    session.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(session, localRepository()));
    session.setSystemProperties(System.getProperties());
    session.setConfigProperties(System.getProperties());
    session.setArtifactTypeRegistry(artifactTypeRegistry());
    session.setDependencyManager(new ClassicDependencyManager());
    session.setArtifactDescriptorPolicy(new SimpleArtifactDescriptorPolicy(true, true));
    session.setDependencySelector(selector);
    session.setDependencyGraphTransformer(transformer);
    session.setTransferListener(new LogTransferListener());
    session.setRepositoryListener(new LogRepositoryListener());

    if (!session.getConfigProperties().containsKey(ConfigurationProperties.REQUEST_TIMEOUT)) {
        session.setConfigProperty(ConfigurationProperties.REQUEST_TIMEOUT, 3 * 60 * 1000);
    }

    return session;
}
 
开发者ID:release-engineering,项目名称:redhat-repository-validator,代码行数:34,代码来源:AppConfig.java

示例9: resolveResources

import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
@Override
public Response<File[]> resolveResources(final AddonId addonId)
{
   RepositorySystem system = container.getRepositorySystem();
   Settings settings = getSettings();
   DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);
   final String mavenCoords = toMavenCoords(addonId);
   Artifact queryArtifact = new DefaultArtifact(mavenCoords);
   session.setDependencyTraverser(new AddonDependencyTraverser(classifier));
   session.setDependencySelector(new AddonDependencySelector(classifier));
   Dependency dependency = new Dependency(queryArtifact, null);

   List<RemoteRepository> repositories = MavenRepositories.getRemoteRepositories(container, settings);

   CollectRequest collectRequest = new CollectRequest(dependency, repositories);
   DependencyResult result;
   try
   {
      result = system.resolveDependencies(session, new DependencyRequest(collectRequest, null));
   }
   catch (DependencyResolutionException e)
   {
      throw new RuntimeException(e);
   }
   List<Exception> collectExceptions = result.getCollectExceptions();
   Set<File> files = new HashSet<File>();
   List<ArtifactResult> artifactResults = result.getArtifactResults();
   for (ArtifactResult artifactResult : artifactResults)
   {
      Artifact artifact = artifactResult.getArtifact();
      if (this.classifier.equals(artifact.getClassifier())
               && !mavenCoords.equals(artifact.toString()))
      {
         continue;
      }
      files.add(artifact.getFile());
   }
   return new MavenResponseBuilder<File[]>(files.toArray(new File[files.size()])).setExceptions(collectExceptions);
}
 
开发者ID:koentsje,项目名称:forge-furnace,代码行数:40,代码来源:MavenAddonDependencyResolver.java

示例10: getRunConfig

import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
private ProjectVersions getRunConfig(MavenProject project) {
    ProjectVersions ret = new ProjectVersions();
    Plugin revapiPlugin = findRevapi(project);
    if (revapiPlugin == null) {
        return ret;
    }

    Xpp3Dom pluginConfig = (Xpp3Dom) revapiPlugin.getConfiguration();

    String[] oldArtifacts = getArtifacts(pluginConfig, "oldArtifacts");
    String[] newArtifacts = getArtifacts(pluginConfig, "newArtifacts");
    String oldVersion = getValueOfChild(pluginConfig, "oldVersion");
    if (oldVersion == null) {
        oldVersion = System.getProperties().getProperty(Props.oldVersion.NAME, Props.oldVersion.DEFAULT_VALUE);
    }
    String newVersion = getValueOfChild(pluginConfig, "newVersion");
    if (newVersion == null) {
        newVersion = System.getProperties().getProperty(Props.newVersion.NAME, project.getVersion());
    }

    String defaultOldArtifact = Analyzer.getProjectArtifactCoordinates(project, oldVersion);
    String defaultNewArtifact = Analyzer.getProjectArtifactCoordinates(project, newVersion);

    if (oldArtifacts == null || oldArtifacts.length == 0) {
        if (!project.getArtifact().getArtifactHandler().isAddedToClasspath()) {
            return ret;
        }
        oldArtifacts = new String[]{defaultOldArtifact};
    }
    if (newArtifacts == null || newArtifacts.length == 0) {
        if (!project.getArtifact().getArtifactHandler().isAddedToClasspath()) {
            return ret;
        }
        newArtifacts = new String[]{defaultNewArtifact};
    }
    String versionRegexString = getValueOfChild(pluginConfig, "versionFormat");
    Pattern versionRegex = versionRegexString == null ? null : Pattern.compile(versionRegexString);

    DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(repositorySystemSession);
    session.setDependencySelector(new ScopeDependencySelector("compile", "provided"));
    session.setDependencyTraverser(new ScopeDependencyTraverser("compile", "provided"));

    if (alwaysCheckForReleaseVersion) {
        session.setUpdatePolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS);
    }

    ArtifactResolver resolver = new ArtifactResolver(repositorySystem, session,
            mavenSession.getCurrentProject().getRemoteProjectRepositories());

    Function<String, Artifact> resolve = gav -> {
        try {
            return Analyzer.resolveConstrained(project, gav, versionRegex, resolver);
        } catch (VersionRangeResolutionException | ArtifactResolutionException e) {
            getLog().warn("Could not resolve artifact '" + gav + "' with message: " + e.getMessage());
            return null;
        }
    };

    ret.oldGavs = Stream.of(oldArtifacts).map(resolve).filter(f -> f != null).toArray(Artifact[]::new);
    ret.newGavs = Stream.of(newArtifacts).map(resolve).filter(f -> f != null).toArray(Artifact[]::new);

    return ret;
}
 
开发者ID:revapi,项目名称:revapi,代码行数:64,代码来源:ReportAggregateMojo.java

示例11: Analyzer

import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
Analyzer(PlexusConfiguration analysisConfiguration, Object[] analysisConfigurationFiles, Artifact[] oldArtifacts,
         Artifact[] newArtifacts, String[] oldGavs, String[] newGavs, MavenProject project,
         RepositorySystem repositorySystem, RepositorySystemSession repositorySystemSession,
         Class<? extends Reporter> reporterType, Map<String, Object> contextData,
         Locale locale, Log log, boolean failOnMissingConfigurationFiles, boolean failOnMissingArchives,
         boolean failOnMissingSupportArchives, boolean alwaysUpdate, boolean resolveDependencies,
         boolean resolveProvidedDependencies,
         String versionRegex, Supplier<Revapi.Builder> revapiConstructor, Revapi sharedRevapi) {

    this.analysisConfiguration = analysisConfiguration;
    this.analysisConfigurationFiles = analysisConfigurationFiles;
    this.oldGavs = oldGavs;
    this.newGavs = newGavs;
    this.oldArtifacts = oldArtifacts;
    this.newArtifacts = newArtifacts;
    this.project = project;
    this.repositorySystem = repositorySystem;

    this.resolveDependencies = resolveDependencies;

    this.versionRegex = versionRegex == null ? null : Pattern.compile(versionRegex);

    DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(repositorySystemSession);
    String[] scopes = resolveProvidedDependencies
            ? new String[] {"compile", "provided"}
            : new String[] {"compile"};

    session.setDependencySelector(new ScopeDependencySelector(scopes));
    session.setDependencyTraverser(new ScopeDependencyTraverser(scopes));

    if (alwaysUpdate) {
        session.setUpdatePolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS);
    }

    this.repositorySystemSession = session;

    this.reporterType = reporterType;
    this.contextData = contextData;
    this.locale = locale;
    this.log = log;
    this.failOnMissingConfigurationFiles = failOnMissingConfigurationFiles;
    this.failOnMissingArchives = failOnMissingArchives;
    this.failOnMissingSupportArchives = failOnMissingSupportArchives;
    this.revapi = sharedRevapi;
    this.revapiConstructor = revapiConstructor;
}
 
开发者ID:revapi,项目名称:revapi,代码行数:47,代码来源:Analyzer.java

示例12: resolveAPIVersion

import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
private Response<String> resolveAPIVersion(AddonId addonId, RepositorySystem system, Settings settings,
         DefaultRepositorySystemSession session)
{
   List<RemoteRepository> repositories = MavenRepositories.getRemoteRepositories(container, settings);
   String mavenCoords = toMavenCoords(addonId);
   Artifact queryArtifact = new DefaultArtifact(mavenCoords);

   session.setDependencyTraverser(new AddonDependencyTraverser(classifier));
   session.setDependencySelector(new DependencySelector()
   {

      @Override
      public boolean selectDependency(Dependency dependency)
      {
         Artifact artifact = dependency.getArtifact();
         if (isAddon(artifact))
         {
            return true;
         }
         return isFurnaceAPI(artifact);
      }

      @Override
      public DependencySelector deriveChildSelector(DependencyCollectionContext context)
      {
         return this;
      }
   });
   CollectRequest request = new CollectRequest(new Dependency(queryArtifact, null), repositories);
   CollectResult result;
   try
   {
      result = system.collectDependencies(session, request);
   }
   catch (DependencyCollectionException e)
   {
      throw new RuntimeException(e);
   }
   List<Exception> exceptions = result.getExceptions();
   String apiVersion = findVersion(result.getRoot().getChildren(), FURNACE_API_GROUP_ID, FURNACE_API_ARTIFACT_ID);
   return new MavenResponseBuilder<String>(apiVersion).setExceptions(exceptions);
}
 
开发者ID:forge,项目名称:furnace,代码行数:43,代码来源:MavenAddonDependencyResolver.java

示例13: resolveAPIVersion

import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
@Override
public Response<String> resolveAPIVersion(AddonId addonId)
{
   RepositorySystem system = container.getRepositorySystem();
   Settings settings = getSettings();
   DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);
   List<RemoteRepository> repositories = MavenRepositories.getRemoteRepositories(container, settings);
   String mavenCoords = toMavenCoords(addonId);
   Artifact queryArtifact = new DefaultArtifact(mavenCoords);

   session.setDependencyTraverser(new AddonDependencyTraverser(classifier));
   session.setDependencySelector(new DependencySelector()
   {

      @Override
      public boolean selectDependency(Dependency dependency)
      {
         Artifact artifact = dependency.getArtifact();
         if (classifier.equals(artifact.getClassifier()))
         {
            return true;
         }
         return (FURNACE_API_GROUP_ID.equals(artifact.getGroupId()) && FURNACE_API_ARTIFACT_ID.equals(artifact
                  .getArtifactId()));
      }

      @Override
      public DependencySelector deriveChildSelector(DependencyCollectionContext context)
      {
         return this;
      }
   });
   CollectRequest request = new CollectRequest(new Dependency(queryArtifact, null), repositories);
   CollectResult result;
   try
   {
      result = system.collectDependencies(session, request);
   }
   catch (DependencyCollectionException e)
   {
      throw new RuntimeException(e);
   }
   List<Exception> exceptions = result.getExceptions();
   String apiVersion = findVersion(result.getRoot().getChildren(), FURNACE_API_GROUP_ID, FURNACE_API_ARTIFACT_ID);
   return new MavenResponseBuilder<String>(apiVersion).setExceptions(exceptions);
}
 
开发者ID:koentsje,项目名称:forge-furnace,代码行数:47,代码来源:MavenAddonDependencyResolver.java

示例14: fetchCollectResult

import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
/**
 *
 * @param artifact
 * @param scope
 *            {@link org.eclipse.aether.util.artifact.JavaScopes}
 * @param dependencySelector
 * @return
 * @throws DependencyCollectionException
 */
public CollectResult fetchCollectResult(Artifact artifact, String scope, DependencySelector dependencySelector)
		throws DependencyCollectionException {
	RepositorySystem repositorySystem = this.maven.getRepositorySystem();
	CollectRequest collectRequest = this.maven.newCollectRequest(artifact, scope);
	DefaultRepositorySystemSession repositorySystemSession = this.maven.newRepositorySystemSession();
	repositorySystemSession.setDependencySelector(dependencySelector);
	return repositorySystem.collectDependencies(repositorySystemSession, collectRequest);
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:18,代码来源:Dependency.java


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