Search in sources :

Example 16 with Version

use of org.eclipse.aether.version.Version 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 17 with Version

use of org.eclipse.aether.version.Version in project spf4j by zolyfarkas.

the class MavenRepositoryUtilsTest method testRepositoryOperations.

@Test
public void testRepositoryOperations() throws VersionRangeResolutionException, ArtifactResolutionException, DependencyResolutionException {
    File localRepo = new File(System.getProperty("java.io.tmpdir"), "m2_repository");
    RemoteRepository mavenCentralRepository = MavenRepositoryUtils.getDefaultRepository();
    List<Version> versions = MavenRepositoryUtils.getVersions(Collections.singletonList(mavenCentralRepository), localRepo, "org.spf4j", "spf4j-core", "[8.3,]");
    LOG.debug("Versions = {}", versions);
    String oldest = versions.get(0).toString();
    Assert.assertEquals("8.3.1", oldest);
    versions = MavenRepositoryUtils.getVersions(Collections.singletonList(mavenCentralRepository), localRepo, "org.spf4j", "spf4j-core", "[,8.3.9-SNAPSHOT)");
    LOG.debug("Versions = {}", versions);
    File resolveArtifact = MavenRepositoryUtils.resolveArtifact(Collections.singletonList(mavenCentralRepository), localRepo, "org.spf4j", "spf4j-core", "sources", "jar", oldest);
    LOG.debug("Artifact file = {}", resolveArtifact);
    Assert.assertTrue(resolveArtifact.canRead());
    Set<File> deps = MavenRepositoryUtils.resolveArtifactAndDependencies(Collections.singletonList(mavenCentralRepository), localRepo, "compile", "jdiff", "jdiff", null, "jar", "1.0.9");
    LOG.debug("Dependency files = {}", deps);
}
Also used : Version(org.eclipse.aether.version.Version) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) File(java.io.File) Test(org.junit.Test)

Aggregations

Version (org.eclipse.aether.version.Version)17 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)9 VersionRangeResolutionException (org.eclipse.aether.resolution.VersionRangeResolutionException)9 Artifact (org.eclipse.aether.artifact.Artifact)8 VersionRangeRequest (org.eclipse.aether.resolution.VersionRangeRequest)8 VersionRangeResult (org.eclipse.aether.resolution.VersionRangeResult)8 File (java.io.File)7 ArrayList (java.util.ArrayList)6 RepositorySystemSession (org.eclipse.aether.RepositorySystemSession)4 Path (java.nio.file.Path)3 Map (java.util.Map)3 DefaultArtifactVersion (org.apache.maven.artifact.versioning.DefaultArtifactVersion)3 Model (org.apache.maven.model.Model)3 SPluginBundleVersion (org.bimserver.interfaces.objects.SPluginBundleVersion)3 RepositorySystem (org.eclipse.aether.RepositorySystem)3 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)3 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)3 FileNotFoundException (java.io.FileNotFoundException)2 FileReader (java.io.FileReader)2 IOException (java.io.IOException)2