Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to simply download a JAR using Maven?

Tags:

maven

jar

How do I download JAR during a build in Maven script?

like image 649
Nadav Benedek Avatar asked Aug 18 '11 15:08

Nadav Benedek


People also ask

Where are jars downloaded by Maven?

The Local Repository Maven's local repository is a directory on the local machine that stores all the project artifacts. When we execute a Maven build, Maven automatically downloads all the dependency jars into the local repository. Usually, this directory is named .


2 Answers

Maven does not work like that. Here's the closest you'll get to my knowledge:

mvn dependency:get -DremoteRepositories=http://repo1.maven.org/maven2/ \                    -DgroupId=junit -DartifactId=junit -Dversion=4.8.2 \                    -Dtransitive=false 

Note that all parameters except transitive are required.
Also note that Maven will download the jar to your local repository, and there's no sensible way (that I know of) to copy it to a local directory.

Reference:

  • dependency:get
like image 169
Sean Patrick Floyd Avatar answered Sep 27 '22 19:09

Sean Patrick Floyd


Or since 3.1, simply as mvn dependency:get -Dartifact=org.springframework:spring-instrument:3.2.3.RELEASE

like image 37
kisna Avatar answered Sep 27 '22 17:09

kisna