本文整理汇总了Java中org.eclipse.aether.DefaultRepositorySystemSession.setDependencyTraverser方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultRepositorySystemSession.setDependencyTraverser方法的具体用法?Java DefaultRepositorySystemSession.setDependencyTraverser怎么用?Java DefaultRepositorySystemSession.setDependencyTraverser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.aether.DefaultRepositorySystemSession
的用法示例。
在下文中一共展示了DefaultRepositorySystemSession.setDependencyTraverser方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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;
}
示例6: 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;
}
示例7: 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);
}
示例8: 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);
}