本文整理了Java中org.eclipse.aether.version.Version
类的一些代码示例,展示了Version
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version
类的具体详情如下:
包路径:org.eclipse.aether.version.Version
类名称:Version
[英]A parsed artifact version.
[中]已解析的工件版本。
代码示例来源:origin: apache/maven
"pom", dependency.getVersion() );
final VersionRangeRequest versionRangeRequest = new VersionRangeRequest( artifact, repositories, context );
versionRangeRequest.setTrace( trace );
if ( versionRangeResult.getHighestVersion() == null )
if ( versionRangeResult.getVersionConstraint() != null
&& versionRangeResult.getVersionConstraint().getRange() != null
&& versionRangeResult.getVersionConstraint().getRange().getUpperBound() == null )
dependency.setVersion( versionRangeResult.getHighestVersion().toString() );
代码示例来源:origin: apache/maven
public boolean isMavenVersion( String versionRange )
{
VersionScheme versionScheme = new GenericVersionScheme();
Validate.notBlank( versionRange, "versionRange can neither be null, empty nor blank" );
VersionConstraint constraint;
try
{
constraint = versionScheme.parseVersionConstraint( versionRange );
}
catch ( InvalidVersionSpecificationException e )
{
throw new IllegalArgumentException( e.getMessage(), e );
}
Version current;
try
{
String mavenVersion = getMavenVersion();
Validate.validState( StringUtils.isNotEmpty( mavenVersion ), "Could not determine current Maven version" );
current = versionScheme.parseVersion( mavenVersion );
}
catch ( InvalidVersionSpecificationException e )
{
throw new IllegalStateException( "Could not parse current Maven version: " + e.getMessage(), e );
}
if ( constraint.getRange() == null )
{
return constraint.getVersion().compareTo( current ) <= 0;
}
return constraint.containsVersion( current );
}
代码示例来源:origin: opensourceBIM/BIMserver
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact(artifact);
rangeRequest.setRepositories(mavenPluginRepository.getRepositories());
List<Version> versions = rangeResult.getVersions();
if (!versions.isEmpty()) {
for (int i=versions.size() - 1; i >= Math.max(0, versions.size() - 3); i--) {
ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
Artifact versionArtifact = new DefaultArtifact(groupId, artifactId, "pom", version.toString());
代码示例来源:origin: feroult/yawp
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;
}
代码示例来源:origin: net.stickycode.plugins/bounds-maven-plugin
protected Version highestVersion(Artifact artifact) throws MojoExecutionException {
VersionRangeRequest request = new VersionRangeRequest(artifact, repositories, null);
VersionRangeResult v = resolve(request);
if (!includeSnapshots) {
List<Version> filtered = new ArrayList<Version>();
for (Version aVersion : v.getVersions()) {
if (!aVersion.toString().endsWith("SNAPSHOT")) {
filtered.add(aVersion);
}
}
v.setVersions(filtered);
}
if (v.getHighestVersion() == null) {
throw (v.getExceptions().isEmpty())
? new MojoExecutionException("Failed to resolve " + artifact.toString())
: new MojoExecutionException("Failed to resolve " + artifact.toString(), v.getExceptions().get(0));
}
return v.getHighestVersion();
}
代码示例来源:origin: apache/maven
String ver = v.toString();
if ( isCompatible( request, ver ) )
String ver = v.toString();
if ( isCompatible( request, ver ) )
代码示例来源:origin: net.oneandone.maven/embedded
/** @return Latest version field from metadata.xml of the repository that was last modified. Never null */
public String latestVersion(Artifact artifact) throws VersionRangeResolutionException, VersionResolutionException {
Artifact range;
VersionRangeRequest request;
VersionRangeResult result;
List<Version> versions;
String version;
// CAUTION: do not use version "LATEST" because the respective field in metadata.xml is not set reliably:
range = artifact.setVersion("[,]");
request = new VersionRangeRequest(range, remote, null);
result = repositorySystem.resolveVersionRange(repositorySession, request);
versions = result.getVersions();
if (versions.size() == 0) {
throw new VersionRangeResolutionException(result, "no version found");
}
version = versions.get(versions.size() - 1).toString();
if (version.endsWith("-SNAPSHOT")) {
version = latestSnapshot(artifact.setVersion(version));
}
return version;
}
代码示例来源:origin: net.aequologica.neo/quintessence-core
RepositorySystemSession session = booter.newRepositorySystemSession(system);
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact(artifact);
List<RemoteRepository> newRepositories = booter.newRepositories(system, session);
if (repositories == null || repositories.size() == 0) {
rangeRequest.setRepositories(newRepositories);
Version lowestVersion = rangeResult.getLowestVersion();
Version newestVersion = rangeResult.getHighestVersion();
repositoryHolder.repositoryId = rangeResult.getRepository(newestVersion).getId();
for (RemoteRepository remoteRepository : newRepositories) {
if (remoteRepository.getId().equals(repositoryHolder.repositoryId)) {
if (newestVersion.toString().endsWith("SNAPSHOT")) {
VersionRequest versionRequest = new VersionRequest();
ret = new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getExtension(), newestVersion.toString());
versionRequest.setArtifact(ret);
versionRequest.addRepository(repositoryHolder.remoteRepository);
ret.getClassifier(),
ret.getExtension(),
resolvedSnapshotVersion==null?newestVersion.toString():resolvedSnapshotVersion);
代码示例来源:origin: org.jboss.galleon/galleon-maven-plugins
@Override
public String getHighestVersion(ArtifactCoords coords, String range) throws ArtifactException {
Artifact artifact = new DefaultArtifact(coords.getGroupId(),
coords.getArtifactId(), coords.getExtension(), range);
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact(artifact);
VersionRangeResult rangeResult;
try {
rangeResult = repoSystem.resolveVersionRange(session, rangeRequest);
} catch (VersionRangeResolutionException ex) {
throw new ArtifactException(ex.getLocalizedMessage(), ex);
}
String version = null;
if (rangeResult != null && rangeResult.getHighestVersion() != null) {
version = rangeResult.getHighestVersion().toString();
}
return version;
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-contract-stub-runner
private String resolveHighestArtifactVersion(String stubsGroup, String stubsModule,
String classifier, String version) {
Artifact artifact = new DefaultArtifact(stubsGroup, stubsModule, classifier,
ARTIFACT_EXTENSION, version);
VersionRangeRequest versionRangeRequest = new VersionRangeRequest(artifact,
this.remoteRepos, null);
VersionRangeResult rangeResult;
try {
rangeResult = this.repositorySystem.resolveVersionRange(this.session,
versionRangeRequest);
if (log.isDebugEnabled()) {
log.debug("Resolved version range is [" + rangeResult + "]");
}
}
catch (VersionRangeResolutionException e) {
throw new IllegalStateException("Cannot resolve version range", e);
}
if (rangeResult.getHighestVersion() == null) {
throw new IllegalArgumentException("For groupId [" + stubsGroup
+ "] artifactId [" + stubsModule + "] " + "and classifier ["
+ classifier
+ "] the version was not resolved! The following exceptions took place "
+ rangeResult.getExceptions());
}
return rangeResult.getHighestVersion() == null ? null
: rangeResult.getHighestVersion().toString();
}
代码示例来源:origin: io.fabric8/fabric-maven
new VersionRangeRequest( artifact, remoteRepos, null ) );
if( versionResult != null ) {
Version v = versionResult.getHighestVersion();
if( v != null ) {
artifact = artifact.setVersion( v.toString() );
代码示例来源:origin: org.jboss.galleon/galleon-maven-plugin
private static MavenArtifactVersion resolveLatest(VersionRangeResult rangeResult) throws MavenUniverseException {
MavenArtifactVersion latestRelease = null;
for (Version version : rangeResult.getVersions()) {
MavenArtifactVersion next = new MavenArtifactVersion(version.toString());
if (latestRelease == null || next.compareTo(latestRelease) > 0) {
latestRelease = next;
}
}
return latestRelease;
}
代码示例来源:origin: org.jboss.forge.furnace/furnace-manager-resolver-maven
List<RemoteRepository> repositories = MavenRepositories.getRemoteRepositories(container, settings);
VersionRangeResult versions = getVersions(system, settings, session, repositories, addonNameSplit, version);
List<Exception> exceptions = versions.getExceptions();
List<Version> versionsList = versions.getVersions();
List<AddonId> addons = new ArrayList<AddonId>();
List<AddonId> snapshots = new ArrayList<AddonId>();
for (Version artifactVersion : versionsList)
AddonId addonId = AddonId.from(addonName, artifactVersion.toString());
if (Versions.isSnapshot(addonId.getVersion()))
代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij
/**
* Returns the latest Google Cloud Java client library BOM version from Maven Central.
*
* @return returns the latest version of the BOM
*/
Optional<String> getLatestBomVersion() {
try {
Version highestVersion = executeBomVersionRangeRequest().getHighestVersion();
return highestVersion == null ? Optional.empty() : Optional.of(highestVersion.toString());
} catch (VersionRangeResolutionException ex) {
logger.warn("Error fetching latest BOM versions from Maven Central", ex);
return Optional.empty();
}
}
代码示例来源:origin: org.eclipse.aether/aether-impl
Artifact originalArtifact = dependency.getArtifact().setVersion( version.toString() );
Dependency d = dependency.setArtifact( originalArtifact );
getRemoteRepositories( rangeResult.getRepository( version ), repositories );
getRemoteRepositories( rangeResult.getRepository( version ), repositories );
DefaultDependencyNode child =
createDependencyNode( relocations, preManaged, rangeResult, version, d, null, repos,
代码示例来源:origin: opensourceBIM/BIMserver
public MavenPluginVersion getLatestVersion() {
Artifact artifact = new DefaultArtifact(groupId + ":" + artifactId + ":LATEST");
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact(artifact);
rangeRequest.setRepositories(mavenPluginRepository.getRepositories());
List<Version> versions = rangeResult.getVersions();
if (!versions.isEmpty()) {
Version version = versions.get(0);
ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
Artifact versionArtifact = new DefaultArtifact(groupId + ":" + artifactId + ":pom:" + version.toString());
代码示例来源:origin: com.google.appengine/gcloud-maven-plugin
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;
}
代码示例来源:origin: net.stickycode.plugins/bounds-maven-plugin
private Version highestVersion(Artifact artifact) throws MojoExecutionException {
VersionRangeRequest request = new VersionRangeRequest(artifact, repositories, null);
VersionRangeResult v = resolve(request);
if (!includeSnapshots) {
List<Version> filtered = new ArrayList<Version>();
for (Version aVersion : v.getVersions()) {
if (!aVersion.toString().endsWith("SNAPSHOT")) {
filtered.add(aVersion);
}
}
v.setVersions(filtered);
}
if (v.getHighestVersion() == null) {
throw (v.getExceptions().isEmpty())
? new MojoExecutionException("Failed to resolve " + artifact.toString())
: new MojoExecutionException("Failed to resolve " + artifact.toString(), v.getExceptions().get(0));
}
return v.getHighestVersion();
}
代码示例来源:origin: opensourceBIM/BIMserver
public String getVersion() {
return version.toString();
}
代码示例来源:origin: org.revapi/revapi-maven-utils
VersionRangeRequest rangeRequest = new VersionRangeRequest(artifact, repositories, null);
List<Version> versions = new ArrayList<>(result.getVersions());
Collections.reverse(versions);
if (versionMatcher.matcher(v.toString()).matches()) {
return resolveArtifact(artifact.setVersion(v.toString()), session);
内容来源于网络,如有侵权,请联系作者删除!