use of org.eclipse.aether.resolution.VersionRangeResult in project pinpoint by naver.
the class DependencyResolver method getVersions.
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;
}
use of org.eclipse.aether.resolution.VersionRangeResult in project pinpoint by naver.
the class DependencyResolver method getNewestVersion.
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();
}
use of org.eclipse.aether.resolution.VersionRangeResult in project bnd by bndtools.
the class BaselineMojo method searchForBaseVersion.
private void searchForBaseVersion(Artifact artifact, List<RemoteRepository> aetherRepos) throws VersionRangeResolutionException {
logger.info("Automatically determining the baseline version for {} using repositories {}", artifact, aetherRepos);
Artifact toFind = new DefaultArtifact(base.getGroupId(), base.getArtifactId(), base.getClassifier(), base.getExtension(), base.getVersion());
Artifact toCheck = toFind.setVersion("(," + artifact.getVersion() + ")");
VersionRangeRequest request = new VersionRangeRequest(toCheck, aetherRepos, "baseline");
VersionRangeResult versions = system.resolveVersionRange(session, request);
logger.debug("Found versions {}", versions.getVersions());
base.setVersion(versions.getHighestVersion() != null ? versions.getHighestVersion().toString() : null);
logger.info("The baseline version was found to be {}", base.getVersion());
}
use of org.eclipse.aether.resolution.VersionRangeResult in project bnd by bndtools.
the class AetherRepository method versions.
@Override
public SortedSet<Version> versions(String bsn) throws Exception {
init();
// Use the index by preference
if (indexedRepo != null)
return indexedRepo.versions(ConversionUtils.maybeMavenCoordsToBsn(bsn));
Artifact artifact = null;
try {
artifact = new DefaultArtifact(bsn + ":[0,)");
} catch (Exception e) {
// ignore non-GAV style dependencies
}
if (artifact == null)
return null;
// Setup the Aether repo session and create the range request
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
session.setLocalRepositoryManager(repoSystem.newLocalRepositoryManager(session, localRepo));
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact(artifact);
rangeRequest.setRepositories(Collections.singletonList(remoteRepo));
// Resolve the range
VersionRangeResult rangeResult = repoSystem.resolveVersionRange(session, rangeRequest);
// Add to the result
SortedSet<Version> versions = new TreeSet<Version>();
for (org.eclipse.aether.version.Version version : rangeResult.getVersions()) {
try {
versions.add(MavenVersion.parseString(version.toString()).getOSGiVersion());
} catch (IllegalArgumentException e) {
// ignore version
}
}
return versions;
}
Aggregations