I though I could use /nexus/service/local/artifact/maven/resolve?r=releases&g=com.mycompany&a=myArtifact&v=LATEST
Then I read about the difference between LATEST and RELEASE.
In Maven 3, LATEST is no longer filled - ok
But RELEASE gives me only the latest released version!
So how can I fetch the HIGHEST version of an artifact?
I need something, which returns version 2.1.3
Any clue?
Here's my maven-metadata.xml from Nexus:
<metadata>
<groupId>com.mycompany</groupId>
<artifactId>myartifact</artifactId>
<versioning>
<latest>1.0.4</latest>
<release>2.0.5</release>
<versions>
<version>1.0.0</version>
<version>1.0.1</version>
<version>1.0.2</version>
<version>1.0.4</version>
<version>1.0.5</version>
<version>1.0.6</version>
<version>1.0.7</version>
<version>2.0.0</version>
<version>2.0.1</version>
<version>2.0.2</version>
<version>2.0.3</version>
<version>2.0.4</version>
<version>2.1.0</version>
<version>2.1.1</version>
<version>2.1.2</version>
<version>2.1.3</version> <!-- released week ago -->
<version>2.0.5</version> <!-- released today -->
</versions>
<lastUpdated>20120531131959</lastUpdated>
</versioning>
</metadata>
Use the code from DefaultArtifactVersion to create version instances from the strings which you can sort using
compareTo()
.The code is in the artifact
Note that this doesn't always work. For example
commons-lang:commons-lang
has the version20030203.000129
which is older than the latest2.6
but sorts higher.