Using the Nexus rest API to get latest artifact version for given groupid/artifactId

chrisst picture chrisst · Oct 27, 2011 · Viewed 83.7k times · Source

I am trying to use the nexus REST api to get the latest version of a maven artifact. I am able to browse to the specific version I am looking for using http://repo.local/service/local/data_index?a=local-turbogears-server&from=0&g=com.turbo&c=bin&v=1.1.9 and if I remove the version parameter I can see every version. However when I try and use RELEASE or LATEST as the version then it returns zero results. I checked the maven-metadata.xml on disk in nexus and there are entries for latest and release. Is there another step I need to take to return the latest version?

I am currently using:

Nexus v. 1.9.2

Answer

Mark O'Connor picture Mark O'Connor · Oct 27, 2011

The following URL will retrieve the latest version of log4j 1.2.x:

http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=log4j&a=log4j&v=LATEST

Documented here

Update

Example using curl:

curl -L "http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=log4j&a=log4j&v=LATEST" -o log4j.jar

Update for Log4j2

Log4j 1.2 is EOL since summer 2015 and is known to be broken in Java 9.

Here is the link for the Log4j artifacts: