本文整理汇总了Java中org.eclipse.aether.resolution.VersionRangeRequest.setArtifact方法的典型用法代码示例。如果您正苦于以下问题:Java VersionRangeRequest.setArtifact方法的具体用法?Java VersionRangeRequest.setArtifact怎么用?Java VersionRangeRequest.setArtifact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.aether.resolution.VersionRangeRequest
的用法示例。
在下文中一共展示了VersionRangeRequest.setArtifact方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLatestVersion
import org.eclipse.aether.resolution.VersionRangeRequest; //导入方法依赖的package包/类
private String getLatestVersion(String groupId, String artifactId, String range,
RepositorySystemSession session, List<RemoteRepository> remotes)
throws VersionRangeResolutionException {
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact(
new DefaultArtifact(String.format("%s:%s:%s", groupId, artifactId, range)));
rangeRequest.setRepositories(remotes);
VersionRangeResult rangeResult = repoSystem.resolveVersionRange(session, rangeRequest);
if (rangeResult.getHighestVersion() != null) {
return rangeResult.getHighestVersion().toString();
}
else {
throw new com.atomist.rug.resolver.maven.DependencyCollectionException(String
.format("Unable to find a version of archive %s:%s.", groupId, artifactId),
properties.repositories());
}
}
示例2: determineNewestVersion
import org.eclipse.aether.resolution.VersionRangeRequest; //导入方法依赖的package包/类
private static String determineNewestVersion(RepositorySystem repoSystem, RepositorySystemSession repoSession, List<RemoteRepository>[] repos) throws MojoExecutionException {
String version;VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact(new DefaultArtifact(SDK_GROUP_ID + ":" + SDK_ARTIFACT_ID + ":[0,)"));
for(List<RemoteRepository> repoList : repos) {
for(RemoteRepository repo : repoList) {
rangeRequest.addRepository(repo);
}
}
VersionRangeResult rangeResult;
try {
rangeResult = repoSystem.resolveVersionRange(repoSession, rangeRequest);
} catch (VersionRangeResolutionException e) {
throw new MojoExecutionException("Could not resolve latest version of the App Engine Java SDK", e);
}
List<Version> versions = rangeResult.getVersions();
Collections.sort(versions);
Version newest = Iterables.getLast(versions);
version = newest.toString();
return version;
}
示例3: findAvailableVersions
import org.eclipse.aether.resolution.VersionRangeRequest; //导入方法依赖的package包/类
public Collection<String> findAvailableVersions(String moduleId) {
Artifact artifact = new DefaultArtifact(groupId, moduleId, "jar", "[0,)");
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact(artifact);
rangeRequest.setRepositories(repos);
VersionRangeResult rangeResult;
try {
rangeResult = system.resolveVersionRange(session, rangeRequest);
} catch (VersionRangeResolutionException e) {
logger.error("The requested range could not be parsed", e);
return Collections.emptyList();
}
// transform List<Version> to a List<String> using toString()
return FluentIterable.from(rangeResult.getVersions()).transform(Functions.toStringFunction()).toList();
}
示例4: resolveVersionRange
import org.eclipse.aether.resolution.VersionRangeRequest; //导入方法依赖的package包/类
private String resolveVersionRange(String groupId, String artifactId, String extension, String version)
throws VersionRangeResolutionException {
org.eclipse.aether.artifact.Artifact aetherArtifact = new org.eclipse.aether.artifact.DefaultArtifact(groupId,
artifactId, extension, version);
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact(aetherArtifact);
rangeRequest.setRepositories(repositories);
VersionRangeResult rangeResult = this.repositorySystem.resolveVersionRange(this.repoSession, rangeRequest);
if (rangeResult == null || rangeResult.getHighestVersion() == null) {
throw new VersionRangeResolutionException(rangeResult, "Unable to resolve version range fram " + groupId
+ ":" + artifactId + ":" + extension + ":" + version);
}
getLog().debug("Available versions: " + rangeResult.getVersions());
return rangeResult.getHighestVersion().toString();
}
示例5: getAvailableVersions
import org.eclipse.aether.resolution.VersionRangeRequest; //导入方法依赖的package包/类
@Override
public List<String> getAvailableVersions(String artifactGroup, String artifactName, List<PluginRepository> remoteRepositories) {
List<String> versions = new ArrayList<>();
try {
// TODO figure out how to force remote check
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact(new DefaultArtifact(artifactGroup, artifactName, "jar", "[0,)"));
if (remoteRepositories != null) {
for (PluginRepository pluginRepository : remoteRepositories) {
rangeRequest.addRepository(
new RemoteRepository.Builder(pluginRepository.getName(), "default", pluginRepository.getUrl()).build());
}
}
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
File tempDir = new File(System.getProperty("java.io.tmpdir"), "temp-local-repo");
tempDir.mkdirs();
LocalRepository localRepo = new LocalRepository(tempDir.getAbsolutePath());
session.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(session, localRepo));
session.setTransferListener(new PluginTransferListener());
session.setRepositoryListener(new PluginRepositoryListener());
VersionRangeResult rangeResult = repositorySystem.resolveVersionRange(session, rangeRequest);
if (rangeResult != null) {
List<Version> versionList = rangeResult.getVersions();
for (Version version : versionList) {
versions.add(version.toString());
}
}
FileUtils.deleteQuietly(tempDir);
} catch (VersionRangeResolutionException e) {
logger.error("", e);
}
return versions;
}
示例6: getLatestLocalVersion
import org.eclipse.aether.resolution.VersionRangeRequest; //导入方法依赖的package包/类
@Override
public String getLatestLocalVersion(String artifactGroup, String artifactName) {
String latestVersion = null;
try {
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact(new DefaultArtifact(artifactGroup, artifactName, "jar", "[0,)"));
VersionRangeResult rangeResult = repositorySystem.resolveVersionRange(repositorySystemSession, rangeRequest);
if (rangeResult != null && rangeResult.getHighestVersion() != null) {
latestVersion = rangeResult.getHighestVersion().toString();
}
} catch (VersionRangeResolutionException e) {
logger.error("", e);
}
return latestVersion;
}
示例7: determineNewestVersion
import org.eclipse.aether.resolution.VersionRangeRequest; //导入方法依赖的package包/类
private static String determineNewestVersion(RepositorySystem repoSystem,
RepositorySystemSession repoSession, List<RemoteRepository>[] repos)
throws MojoExecutionException {
String version;
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact(new DefaultArtifact(SDK_GROUP_ID + ":" + SDK_ARTIFACT_ID + ":[0,)"));
for (List<RemoteRepository> repoList : repos) {
for (RemoteRepository repo : repoList) {
rangeRequest.addRepository(repo);
}
}
VersionRangeResult rangeResult;
try {
rangeResult = repoSystem.resolveVersionRange(repoSession, rangeRequest);
} catch (VersionRangeResolutionException e) {
throw new MojoExecutionException(
"Could not resolve latest version of the App Engine Java SDK", e);
}
List<Version> versions = rangeResult.getVersions();
Collections.sort(versions);
Version newest = Iterables.getLast(versions);
version = newest.toString();
return version;
}
示例8: getVersions
import org.eclipse.aether.resolution.VersionRangeRequest; //导入方法依赖的package包/类
public List<Version> getVersions(Artifact artifact) throws VersionRangeResolutionException {
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact( artifact );
rangeRequest.setRepositories( repositories );
VersionRangeResult rangeResult = system.resolveVersionRange( session, rangeRequest );
List<Version> versions = new ArrayList<Version>(rangeResult.getVersions());
Collections.sort(versions);
return versions;
}
示例9: getLastVersion
import org.eclipse.aether.resolution.VersionRangeRequest; //导入方法依赖的package包/类
/**
* gets the last version of the current artifact, not including the current
* one.
*
* @return
* @throws MojoExecutionException
*/
private org.eclipse.aether.version.Version getLastVersion()
throws MojoExecutionException {
// build the artifact description with version range from 0 up to (non
// inclusive) current version
String artifactDescription = ARTIFACT_DESCRIPTION.replace("groupId",
groupId);
artifactDescription = artifactDescription.replace("artifactId", name);
artifactDescription = artifactDescription.replace("version", version);
Artifact artifact = new DefaultArtifact(artifactDescription);
getLog().info(
String.format("searching for artifacts in range %s",
artifactDescription));
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact(artifact);
rangeRequest.setRepositories(projectRepos);
VersionRangeResult rangeResult;
try {
rangeResult = repoSystem.resolveVersionRange(repoSession,
rangeRequest);
List<org.eclipse.aether.version.Version> versions = rangeResult
.getVersions();
getLog().debug(
String.format("found versions %s",
rangeResult.getVersions()));
// could not find a previous version
if (versions.isEmpty()) {
return null;
}
org.eclipse.aether.version.Version lastVersion = versions
.get(versions.size() - 1);
getLog().debug(String.format("previous version is %s", lastVersion));
return lastVersion;
} catch (VersionRangeResolutionException e) {
throw new MojoExecutionException("could not calculate versions", e);
}
}
示例10: getNewestVersion
import org.eclipse.aether.resolution.VersionRangeRequest; //导入方法依赖的package包/类
public String getNewestVersion(String groupId, String artifactId) throws VersionRangeResolutionException {
Artifact artifact = new DefaultArtifact(groupId, artifactId, "jar", "[0,)");
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact(artifact);
rangeRequest.setRepositories(repositories);
VersionRangeResult rangeResult = system.resolveVersionRange( session, rangeRequest );
Version newestVersion = rangeResult.getHighestVersion();
return newestVersion.toString();
}