sofarsogood
sofarsogood

Reputation: 291

Latest version of an artifact from Apache Archiva

Is there some kind of parametrized url on archiva, where I can get the latest snapshot/release of an artifact? sth like https://myhappyarchiva.com/archiva/repository/com.example/com/example/myproject/LATEST/myproject-LATEST.jar

Upvotes: 4

Views: 2371

Answers (2)

Jordan Stewart
Jordan Stewart

Reputation: 3395

Try something like: "http://myhappyarchiva.com/archiva/restServices/archivaServices/searchService/artifact?r=#releases&g=com.myhappyarchiva&a=myproject&v=LATEST"

The basics are: "http://[host_name]/archiva/restServices/archivaServices/searchService/artifact?r=[release_option]&g=[group_id]&a=[artifact_id]&v=[version]&c=[classifer]"

  • [host_name] is like: dev.foo.com
  • [release_option] is like: "snapshots" or "releases"
  • [group_id] is like: com.foo
  • [version] is like: LATEST or some number like 1.0
  • [classifer] is like: javadoc, sources, or assembly

The labels are displayed in the tables on archiva. So you can easily look up the references.

I believe you can use "p" to be packaging as well. It can be like: "jar","pom","javadoc" basically file types. So that would look like, "&p=jar" added onto the request.

It you are following the requests it sometimes goes through a 307 temporary redirect and 302 found redirect before the repo starts to download.

You do this with curl or wget. Or in a script (I made a ruby script).

Example of wget: https://archiva.apache.org/docs/2.2.0/userguide/querying-artifacts.html

Upvotes: 3

Brett Porter
Brett Porter

Reputation: 5867

That feature is not yet available, however you might like to file an issue at http://jira.codehaus.org/browse/MRM. A related issue is http://jira.codehaus.org/browse/MRM-805.

To achieve this today, the best thing to do is either:

  • use the XMLRPC interface to retrieve the versions and select the latest (you can use Maven libraries to do that if it's for Maven) [1] [2]
  • if you know the repository will be a Maven repository, you can grab the maven-metadata.xml file from Archiva and read the <release> or <latest> element

Upvotes: 2

Related Questions