本文整理汇总了Java中org.eclipse.aether.version.Version类的典型用法代码示例。如果您正苦于以下问题:Java Version类的具体用法?Java Version怎么用?Java Version使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Version类属于org.eclipse.aether.version包,在下文中一共展示了Version类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateRugCompatibility
import org.eclipse.aether.version.Version; //导入依赖的package包/类
public static void validateRugCompatibility(ArtifactDescriptor artifact,
List<ArtifactDescriptor> dependencies) {
Optional<ArtifactDescriptor> rugArtifact = dependencies.stream()
.filter(f -> f.group().equals(Constants.GROUP)
&& f.artifact().equals(Constants.RUG_ARTIFACT))
.findAny();
if (rugArtifact.isPresent()) {
try {
Version version = VERSION_SCHEME.parseVersion(rugArtifact.get().version());
VersionRange range = VERSION_SCHEME.parseVersionRange(Constants.RUG_VERSION_RANGE);
if (!range.containsVersion(version)) {
throw new VersionException(String.format(
"Installed version of Rug CLI is not compatible with archive %s.\n\n"
+ "The archive depends on %s:%s (%s) which is incompatible with Rug CLI (compatible version range %s).\n"
+ "Please update to a more recent version of Rug CLI or change the Rug archive to use a supported Rug version.",
ArtifactDescriptorUtils.coordinates(artifact), Constants.GROUP,
Constants.RUG_ARTIFACT, version.toString(), range.toString()));
}
}
catch (InvalidVersionSpecificationException e) {
// Since we were able to resolve the version it is impossible for this to happen
}
}
}
示例2: determineNewestVersion
import org.eclipse.aether.version.Version; //导入依赖的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: resolveLatestVersionRange
import org.eclipse.aether.version.Version; //导入依赖的package包/类
private Artifact resolveLatestVersionRange(Dependency dependency, String version) throws MojoExecutionException {
Matcher versionMatch = matchVersion(version);
Artifact artifact = new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(),
dependency.getType(), dependency.getClassifier(), version);
if (versionMatch.matches()) {
Version highestVersion = highestVersion(artifact);
String upperVersion = versionMatch.group(1) != null
? versionMatch.group(1)
: "";
String newVersion = "[" + highestVersion.toString() + "," + upperVersion + ")";
artifact = artifact.setVersion(newVersion);
return artifact;
}
else {
return artifact;
}
}
示例4: highestVersion
import org.eclipse.aether.version.Version; //导入依赖的package包/类
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();
}
示例5: latestRelease
import org.eclipse.aether.version.Version; //导入依赖的package包/类
public String latestRelease(Artifact artifact) throws VersionRangeResolutionException {
List<Version> versions;
Version version;
versions = availableVersions(artifact.setVersion("[" + artifact.getVersion() + ",]"));
// ranges also return SNAPSHOTS. The release/compatibility notes say they don't, but the respective bug
// was re-opened: http://jira.codehaus.org/browse/MNG-3092
for (int i = versions.size() - 1; i >= 0; i--) {
version = versions.get(i);
if (!version.toString().endsWith("SNAPSHOT")) {
return version.toString();
}
}
return artifact.getVersion();
}
示例6: UpgradePath
import org.eclipse.aether.version.Version; //导入依赖的package包/类
protected UpgradePath(Element oldEntry, String oldPath, String groupID,
String artifactID, VersionRangeResult versions, Version version) {
this.oldEntry = oldEntry;
this.oldPath = oldPath.endsWith("/") ? oldPath : oldPath + "/";
this.groupID = groupID;
this.artifactID = artifactID;
this.versions = versions;
this.version = version;
}
示例7: newerVersion
import org.eclipse.aether.version.Version; //导入依赖的package包/类
public static Optional<String> newerVersion() {
try {
VersionScheme scheme = new GenericVersionScheme();
Version runningVersion = scheme.parseVersion(readVersion().orElse("0.0.0"));
Version onlineVersion = scheme.parseVersion(readOnlineVersion().orElse("0.0.0"));
return (onlineVersion.compareTo(runningVersion) > 0
? Optional.of(onlineVersion.toString())
: Optional.empty());
}
catch (InvalidVersionSpecificationException e) {
}
return Optional.empty();
}
示例8: parseVersion
import org.eclipse.aether.version.Version; //导入依赖的package包/类
public static Version parseVersion(String version) {
try {
return VERSION_SCHEME.parseVersion(version);
}
catch (InvalidVersionSpecificationException e) {
throw new CommandException(
String.format("Unable to parse version number '%s'", version), e);
}
}
示例9: doWithRepositorySession
import org.eclipse.aether.version.Version; //导入依赖的package包/类
protected void doWithRepositorySession(RepositorySystem system, RepositorySystemSession session,
ArtifactSource source, Manifest manifest, Artifact zip, Artifact pom, Artifact metadata,
CommandLine commandLine) {
Set<String> ids = org.springframework.util.StringUtils
.commaDelimitedListToSet(CommandLineOptions.getOptionValue("id").orElse(""));
if (CommandLineOptions.hasOption("U")) {
String group = manifest.group();
String artifact = manifest.artifact();
Version version = VersionUtils.parseVersion(manifest.version());
SearchCommand search = new SearchCommand();
Map<String, List<Operation>> operations = search.search(SettingsReader.read(), null,
new Properties(), null);
operations.values().stream().filter(ops -> ops.size() > 0).forEach(ops -> {
Archive archive = ops.get(0).archive();
if (archive.group().equals(group) && archive.artifact().equals(artifact)
&& !"global".equals(archive.scope())) {
if (version
.compareTo(VersionUtils.parseVersion(archive.version().value())) > 0) {
ids.add(archive.scope());
}
}
});
}
List<org.eclipse.aether.repository.RemoteRepository> deployRepositorys = getDeployRepositories(
ids);
deployRepositorys.forEach(
r -> publishToRepository(system, session, source, manifest, zip, pom, metadata, r));
}
示例10: onExitArtifactId
import org.eclipse.aether.version.Version; //导入依赖的package包/类
@Nullable
public Maven2Metadata onExitArtifactId() {
checkState(artifactId != null);
log.debug("<- GA: {}:{}", groupId, artifactId);
if (baseVersions.isEmpty()) {
log.debug("Nothing to generate: {}:{}", groupId, artifactId);
return null;
}
Iterator<Version> vi = baseVersions.descendingIterator();
String latest = vi.next().toString();
String release = latest;
while (release.endsWith(Constants.SNAPSHOT_VERSION_SUFFIX) && vi.hasNext()) {
release = vi.next().toString();
}
if (release.endsWith(Constants.SNAPSHOT_VERSION_SUFFIX)) {
release = null;
}
return Maven2Metadata.newArtifactLevel(
DateTime.now(),
groupId,
artifactId,
latest,
release,
Iterables.transform(baseVersions, new Function<Version, String>()
{
@Override
public String apply(final Version input) {
return input.toString();
}
}));
}
示例11: parseVersion
import org.eclipse.aether.version.Version; //导入依赖的package包/类
@Nullable
private Version parseVersion(final String version) {
try {
return versionScheme.parseVersion(version);
}
catch (InvalidVersionSpecificationException e) {
log.warn("Invalid version: {}", version, e);
return null;
}
}
示例12: detectAllVersionsOf
import org.eclipse.aether.version.Version; //导入依赖的package包/类
public ResolvedProject detectAllVersionsOf(ProjectCoordinates project) throws RepositoryException {
Artifact artifact = new DefaultArtifact(project.groupId(), project.artifactId(), "jar", "[0,)");
Stream<String> versions = repositorySystem
.resolveVersionRange(
repositorySystemSession,
new VersionRangeRequest(artifact, singletonList(mavenCentral), NULL_CONTEXT))
.getVersions().stream()
.map(Version::toString);
return new ResolvedProject(project, project.toArtifactsWithVersions(versions));
}
示例13: isNewer
import org.eclipse.aether.version.Version; //导入依赖的package包/类
@Override
public boolean isNewer(Plugin first, Plugin second) {
try {
GenericVersionScheme versionScheme = new GenericVersionScheme();
Version firstVersion = versionScheme.parseVersion(first.getArtifactVersion());
Version secondVersion = versionScheme.parseVersion(second.getArtifactVersion());
return firstVersion.compareTo(secondVersion) > 0;
} catch (Exception e) {
return false;
}
}
示例14: getAvailableVersions
import org.eclipse.aether.version.Version; //导入依赖的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;
}
示例15: isUpdateAvailable
import org.eclipse.aether.version.Version; //导入依赖的package包/类
public boolean isUpdateAvailable() {
try {
if (latestArtifactVersion != null && artifactVersion != null) {
Version latest = versionScheme.parseVersion(latestArtifactVersion);
Version current = versionScheme.parseVersion(artifactVersion);
return current.compareTo(latest) < 0;
} else {
return false;
}
} catch (InvalidVersionSpecificationException e) {
return false;
}
}