4

I am writing a script for deploying java application. The scenarion is simple:

  1. Download pusblished application (jar) from repository to local folder.
  2. Run java with jar

How can I download this jar from maven repo to local folder?

Important

  1. The question is not about resolving one artifact. Here is a solution to donwload single artifact to local repository, but I want to specified folder.
  2. Also the solution should work from command line without pom file. E.g. run mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:copy will fail, because it runs only in folder where pom.xml is present.
Community
  • 1
  • 1
Cherry
  • 31,309
  • 66
  • 224
  • 364
  • It's usually possible to grab jar files individually at [Maven Repository](http://mvnrepository.com/). Note that you'll have to manually track dependencies your way (yuck). If you have a pom file, you could could let maven populate your `.m2` folder – Elliott Frisch Dec 10 '14 at 06:05
  • 1
    you can use curl utility to download individual files from maven repo. example `curl http://central.maven.org/maven2/commons-logging/commons-logging/1.2/commons-logging-1.2.jar >> commons-logging.jar` – Adi Dec 10 '14 at 06:08

1 Answers1

7

Try dependency:get like this:

mvn dependency:get -DrepoUrl=http://repo.maven.apache.org/maven2/ -Dartifact=org.springframework:spring-context:4.0.4.RELEASE:jar -Dtransitive=false -Ddest=spring-context-4.0.4.RELEASE.jar
Cherry
  • 31,309
  • 66
  • 224
  • 364
Evgeniy Dorofeev
  • 133,369
  • 30
  • 199
  • 275
  • Do you know a minimal version or dependecy plugin? I have tried this with version 2.1 and it did not work. But with version 2.9 it works :) – Cherry Dec 10 '14 at 06:39