Eclipse Aether doesn't seem to return the correct release when I try to resolve a LATEST
version:
val artifact = DefaultArtifact("org.testng:testng:LATEST")
val versionResult = system.resolveVrsion(session, VersionRequest(artifact, repositories, null))
println(versionResult)
produces:
6.9.8 @ maven (https://jcenter.bintray.com/, default, releases+snapshots)
However, 6.9.10 is the latest, and JCenter is reporting it correctly, both in the directory and also in the maven-metadata.xml
:
<metadata>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
<versioning>
<latest>6.9.10</latest>
<release>6.9.10</release>
Why am I getting 6.9.8
instead of 6.9.10
?
There are two things which might the cause of your problem. First you assume that the magic word LATEST
is supported by Aether and if i remember correctly (and looking into the code of Aether it is not supported). This means you should use a version range to get the latest.
Furthermore if you have a version range you need to call resolveVersionRange(...)
instead of resolveVersion(..)
.
String versionRange = "[0,)";
Artifact artifact =
new DefaultArtifact( "org.testng:testng:jar:" + versionRange );
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact( artifact );
rangeRequest.setRepositories( remoteRepos );
VersionRangeResult rangeResult = repository.resolveVersionRange( repositorySystemSession, rangeRequest );
List<Version> versions = rangeResult.getVersions();
The above is a slightly modified version taken from a plugin i wrote. There is also a ctor of DefaultArtifact which contains only the appropriate parameters which might be a better alternative to use instead of concatenating the strings.