Maven is not only great for dependency management, you can also download jars (which are called “artifacts” in Maven parlor) directly using the dependency:get goal.

The only thing you have to have in mind is the full artifact id which is easy to remember for prominent libraries such as the Apache Commons (org.apache.commons:commons-XX:VERSION) or Spring (org.springframework:spring-XX:VERSION).

As an example, the following command download the Apache Commons Math3 library (3.0) and stores it as /tmp/commons-math3.jar:

mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get 
   -Dartifact=org.apache.commons:commons-math3:3.0    
   -Ddest=/tmp/commons-math3.jar

Even though this one-lines seems to be simple, it took me some time to figure out how this command works:

  • Make sure you use the fully qualified plugin name and version 2.4. Otherwise the -Ddest parameter will not work.
  • The -Ddest parameter needs to be a filename, not a directory. The denoted file is overwritten in case of conflict.

Some Useful Artifacts to remember

If you want to look up the artifact id of an artifact then take a look at the Maven Central Search. Just some examples:

  • org.apache.commons:commons-math3:3.0
  • org.apache.commons:commons-io:1.3.2
  • junit:junit:4.10

Links

  • [1] dependency:get Reference
  • [2] Maven Central Search