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();
}
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);
}
Aggregations