Is there a 'correct' or common way of copying the latest release build from a maven repo to a server?

Tag: maven Author: helpmnb Date: 2010-10-19

I have only fairly recently started using Maven (2.2.1), and I have Artifactory running on the local network, which is where my release versions deploy to.

Currently I have made a dodgy Maven plugin that scp's a release version .jar or .war file to a separate distribution server that puts the new files on the live server overnight.

Is there any more standard/correct way of getting the latest release version of a project from a maven repository and copying it to some location?

Or, is there an easy way to query Artifactory via a shell script or something to retrieve URLs for the latest version of a project, plus it's dependencies?

Best Answer

Not sure about Artifactory but in Nexus (other maven repository manager) it's certainly possible. We used to have a shell script which would query Nexus repository (over http using wget and awk) and pull new releases of our project every night for automated deployment.

Once you have your project you could pull all dependencies for it using maven, e.g:

mvn dependency:resolve

comments:

I'm aware that you can use maven to resolve dependencies as you mentioned, but I assumed that with the way Maven elaborately builds projects and places it all nicely in a repository - that there would be a simple/common way to query a repository "Get me the latest version of an artifact, and it's dependencies".
Repository is just a place for artifacts - and not necessary for maven or java only so 'get latest version AND dependencies' is not possible.