Maven: how to download dependencies from the command-line or from a Mojo

Recently I had to download dependencies from a Maven plugin (Mojo). But I encountered difficulties and want to tell you my conclusion. Here is what I tried:


Shrinkwrap resolver is a JBoss OSS library. For unknown reasons it was sometimes not downloading the latest artifacts from the repository but relied on the outdated ones in the local repo instead. I surely misconfigured something but could not find what…

Apache Archiva REST API

In theory, a simple call to the webservice should have returned my artifact. But (again) for unknown reasons, it would sometimes fail and return a zero byte file.

For exemple, this call fails:

wget "http://myrepoURL:8090/restServices/archivaServices/searchService/artifact?"

but this one succeeds:

wget "http://myrepoURL:8090/restServices/archivaServices/searchService/artifact?"

And I am sure the 2.1.0 version exists and is the latest…


get goal

mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get

=> OK but in previous version (2.X) we used to have parameter “dest” which is now deprecated. So we cannot point the download to a specific directory: it resolves to the local repo only.

copy goal

mvn dependency:copy -DoutputDirectory=. -DuseBaseVersion=true

This is the way I should have tried first ! I don’t know why but I thought the dependency:copy would need a pom to download dependencies. In fact this is not true, you can use it on the command line.

And as you can use it on the command line, you can also use it from inside another Mojo (Maven plugin) by using the Mojo executor. Only caveat is that you do not get a handle on the file just downloaded but you know it’s filename in advance. It is of the form -.jar if you make sure to use the -DuseBaseVersion=true parameter to avoid the timestamp replacing the “-SNAPSHOT” suffix.


Tutorial: CXF Webservice using Maven & an XML Catalog

I’ve just published on Github a tutorial about separating the webservice (with WSDL) Maven project from the project containing the XSD. The goal is to enhance all projects overall testability.

The tutorial is available in the project wiki on Github:

The Maven projects are available on Github too: