I'm using the command below to download a maven jar from Nexus through the command line.
call mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DrepoUrl=http://10.101.15.190:8081/nexus/content/repositories/releases/ -Dartifact=bits:update-service:1.0.3 -Ddest=Setups/Services/update-service.jar
But what I get is a jar without dependencies. There is already a jar with dependencies in Maven with the name update-service-1.0.4-jar-with-dependencies.jar
I tried the following:
call mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DrepoUrl=http://10.101.15.190:8081/nexus/content/repositories/releases/ -Dartifact=bits:update-service:1.0.3[:packaging[:jar]] -Ddest=Setups/Services/update-service.jar
But it returns the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.4:get (default-cli) on project standalone-pom: Couldn't download artifact: Missing:
[ERROR] ----------
[ERROR] 1) bits:update-service:packaging[:jar]]:1.0.3[
[ERROR]
[ERROR] Try downloading the file manually from the project website.
[ERROR]
[ERROR] Then, install it using the command:
[ERROR] mvn install:install-file -DgroupId=bits -DartifactId=update-service -Dversion=1.0.3[ -Dclassifier=jar]] -Dpackaging=packaging[ -Dfile=/path/to/file
[ERROR]
[ERROR] Alternatively, if you host your own repository you can deploy the file there:
[ERROR] mvn deploy:deploy-file -DgroupId=bits -DartifactId=update-service -Dversion=1.0.3[ -Dclassifier=jar]] -Dpackaging=packaging[ -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
[ERROR]
[ERROR] Path to dependency:
[ERROR] 1) org.apache.maven.plugins:maven-downloader-plugin:jar:1.0
[ERROR] 2) bits:update-service:packaging[:jar]]:1.0.3[
[ERROR]
[ERROR] ----------
[ERROR] 1 required artifact is missing.
[ERROR]
[ERROR] for artifact:
[ERROR] org.apache.maven.plugins:maven-downloader-plugin:jar:1.0
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR] central (https://repo.maven.apache.org/maven2, releases=true, snapshots=false),
[ERROR] temp (http://10.101.15.190:8081/nexus/content/repositories/releases/, releases=true, snapshots=true)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Question: What is the correct way to download a jar with dependencies?
jar-with-dependencies
in this case is a Maven classifier
:
The classifier allows to distinguish artifacts that were built from the same POM but differ in their content. It is some optional and arbitrary string that - if present - is appended to the artifact name just after the version number.
That is, the 1.0.4
jar and its with-dependencies variant differ in their Maven coordinates via the classifier.
Hence, using the maven-dependency-plugin
and its get
goal you can specify a classifier
via the classifier
option:
The classifier of the artifact to download. Ignored if
artifact
is used.
However, you are indeed using the artifact
option already, hence the option above will be ignored as per documentation.
If you look at the documentation of the artifact
option though:
A string of the form
groupId:artifactId:version[:packaging][:classifier]
.
Look at its last (optional) token, [:classifier]
. This is exactly what you are missing.
Your artifact
option should be as following:
-Dartifact=bits:update-service:1.0.4:jar:jar-with-dependencies
Note: you actually already used it incorrectly when specifying:
-Dartifact=bits:update-service:1.0.3[:packaging[:jar]]
The squared brackets [..]
indicates optional parameters, you should not specify them in your command line invocation. Moreover the packaging
string there specify what value to put: again, you should not specify it, but just replace it with the corresponding value (in this case jar
).
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