Search in sources :

Example 1 with VersionRangeResult

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;
}
Also used : VersionRangeResult(org.eclipse.aether.resolution.VersionRangeResult) Version(org.eclipse.aether.version.Version) ArrayList(java.util.ArrayList) VersionRangeRequest(org.eclipse.aether.resolution.VersionRangeRequest)

Example 2 with VersionRangeResult

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();
}
Also used : VersionRangeResult(org.eclipse.aether.resolution.VersionRangeResult) Version(org.eclipse.aether.version.Version) VersionRangeRequest(org.eclipse.aether.resolution.VersionRangeRequest) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Example 3 with VersionRangeResult

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());
}
Also used : VersionRangeResult(org.eclipse.aether.resolution.VersionRangeResult) VersionRangeRequest(org.eclipse.aether.resolution.VersionRangeRequest) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Example 4 with VersionRangeResult

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;
}
Also used : VersionRangeResult(org.eclipse.aether.resolution.VersionRangeResult) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) URISyntaxException(java.net.URISyntaxException) TransferCancelledException(org.eclipse.aether.transfer.TransferCancelledException) ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) Version(aQute.bnd.version.Version) MavenVersion(aQute.bnd.version.MavenVersion) TreeSet(java.util.TreeSet) VersionRangeRequest(org.eclipse.aether.resolution.VersionRangeRequest) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Aggregations

VersionRangeRequest (org.eclipse.aether.resolution.VersionRangeRequest)4 VersionRangeResult (org.eclipse.aether.resolution.VersionRangeResult)4 Artifact (org.eclipse.aether.artifact.Artifact)3 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)3 Version (org.eclipse.aether.version.Version)2 MavenVersion (aQute.bnd.version.MavenVersion)1 Version (aQute.bnd.version.Version)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)1 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)1 TransferCancelledException (org.eclipse.aether.transfer.TransferCancelledException)1