Nexus Support for 'Latest' Version

On a recent Maven (2.2.1) project some dependencies are specified using <version>LATEST</version> to lookup the latest release of an artefact in our repository. Nexus is the repository manager and it's able to determine the latest version for Maven to download and include in the build.

During some recent changes to the repositories used in Nexus this feature stopped working, so I did a little digging to find out what LATEST really means and how it's supported by Nexus.

The first thing I found is that each artefact has some metadata maintained by Nexus whenever a new version is uploaded. This metadata sometimes includes an element <latest>1.3</latest>. When this element is present I can resolve <version>LATEST</latest> but when it's missing the lookup fails. So how is this element present in some repositories and missing others?

There appears to be 4 rules:

1. If your artefact is looked up via a Nexus Group repository, Nexus will (dynamically?) ensure that the <latest> element is added to the metadata for the artefact regardless of whether or not it's present in the underlying Hosted repositories metadata.xml.

2. If your artefact is looked up directly using a Hosted repository then LATEST only works if the <latest> element is present in the stored metadata.xml.

3. If you uploaded the artefact using the "mvn deploy" command then the <latest> element is not created or updated. I added -DupdateReleaseInfo=true but that just adds a <release> element which doesn't help.

4. If you manually use the Nexus UI to upload the artefact, then the <latest> element is created or updated, and so maven can then find LATEST correctly.

I did a couple of tests using Nexus 1.8.1 and observed the same behaviour.

So using a Group works fine, but what I'd really prefer is for "mvn deploy" to set the <latest> element in the artefact's metadata.

This site uses cookies. Continue to use the site as normal if you are happy with this, or read more about cookies and how to manage them.