简体   繁体   中英

How to download JAR with classifier from Maven repository?

I am trying to download JAR named mygroup-myid-myversion-jar-with-dependencies.jar from maven repository and tried commands

mvn -q org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=MYURL -Dartifact=mygroups:myid:myversion:jar-with-dependencies

mvn -q org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=MYURL -Dartifact=mygroups:myid:myversion-jar-with-dependencies

And both failed with error of being unable to find artifact.

Is this addendum called "classifier"?

How to donload JAR with classifier?

Use -Dclassifier=<classifier> or -Dclassifiers=<classifiers> if you have more to download.

This worked for me:

mvn com.googlecode.maven-download-plugin:download-maven-plugin:artifact -DgroupId=org.jolokia -DartifactId=jolokia-jvm -Dversion=1.6.0 -Dclassifier=agent 

This one happened to me. I have a remote repository on one of the internet sites and our internal nexus are not getting those dependencies remotely from this host. We have a security setup that only nexus server can connect from outside world and our dev machines have no access to those kinds of remote repository hosts.

All of the artifacts are fine and can be downloaded via proxy repository but some are not, specially like this artifact with dependency classifier below.

<dependency>
    <groupId>com.asset</groupId>
    <artifactId>integration-adapter</artifactId>
    <version>1.28.76</version>
    <classifier>jar-with-dependencies</classifier>
</dependency>

Here are the steps that works for our development teams.

1.) As I'm admin I can remote download those problematic artifacts.

2.) From a secured host, make this file available.

3.) Follow this link from Nexus https://support.sonatype.com/hc/en-us/articles/213465818-How-can-I-programmatically-upload-an-artifact-into-Nexus-2-

4.) This is how I build/deploy to an internal repo so clients can download during their own specific builds for their projects.

mvn deploy:deploy-file -DgroupId=com.asset -DartifactId=integration-adapter -Dversion=1.28.76 -Dclassifier=jar-with-dependencies -DgeneratePom=true -Dpackaging=jar -DrepositoryId=nexus -Durl="http://your-nexus-host:8081/nexus/content/repositories/repo-releases/" -Dfile=integration-adapter-1.28.76-jar-with-dependencies.jar -DupdateReleaseInfo=true

Doing above way creates pom files and meta data in our corporate nexus so maven clients can download those artifacts.

5.) At your .pom file please add these dependencies below:

Looks like in this remote repository (the external host) these files were uploaded directly that is why there are missing maven pom files and we as consumers/clients cannot build it as normal with other working artifacts they have.

Note : So if your are publishing artifacts to the outside world and make your artifacts downloadable make sure you know and read on step 3 above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM