I would like something like the following.
I want just an utility that is able to download jars and their dependencies from the Maven Repository without imposing no constraints on how my project should be built.
I would like something like this:
download-jar --dest=lib/ 'commons-io:commons-io:jar:1.4'
It should be able to download also the dependencies.
Update:
I wouldn't know about a pom.xml should be structured.
The only task I need to be accomplished is the download of the jars, I would like have a tool that could accomplish this task that doesn't bother me with superflous information.
There is something like that?
If you want to download maven dependencies into your lib directory use the dependency plugin with the copy-dependencies
function.
mvn -DoutputDirectory=./lib -DincludeArtifactIds=commons-logging,commons-io dependency:copy-dependencies
Without the -DincludeArtifactIds
part you'll download every dependency.
If you want to download a an artifact without having a specific project *see below** :
mvn -DgroupId=commons-io -DartifactId=commons-io -Dversion=1.4 dependency:get
Resources :
On the same topic :
Interesting comments :
No need to setup a POM, no need to develop your own tool, use mvn dependency:get. That's the right answer to this question.
I also had to specify -DrepoUrl
, after getting the error message:
Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.1:get
(default-cli) on project standalone-pom: The parameters 'repositoryUrl'
for goal org.apache.maven.plugins:maven-dependency-plugin:2.1:get are
missing or invalid -> [Help 1]
So here is the command I used:
mvn -DgroupId=edu.umd -DartifactId=cloud9 -Dversion=1.3.5 \
-DrepoUrl="http://repo1.maven.org/maven2" dependency:get
Furthemore, -Ddest=~
didn't work. It always insisted on installing the jar to ~/.m2/repository
.
Maven3 uses dependency plugin v2.1 by default:
$ mvn dependency:get -DrepoUrl=http://download.java.net/maven/2/ \
-DgroupId=commons-io -DartifactId=commons-io -Dversion=1.4
With Maven2 is still necessary to write the canonical name:
$ mvn2 org.apache.maven.plugins:maven-dependency-plugin:2.1:get \
-DrepoUrl=http://download.java.net/maven/2/ \
-DgroupId=commons-io -DartifactId=commons-io -Dversion=1.4
Use parameter artifact
to set the name of the artifact as group:artifact:version:
$ mvn dependency:get -DrepoUrl=http://download.java.net/maven/2/ \
-Dartifact=commons-io:commons-io:1.4
Use LATEST
to download the latest version of the artifact:
$ mvn dependency:get -DrepoUrl=http://download.java.net/maven/2/ \
-Dartifact=commons-io:commons-io:LATEST
You should take a look at the maven dependency plugin, maybe ... and especially its go-offline mojo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With