简体   繁体   中英

How can I recursively download an artifact and all dependencies into a directory?

I don't have an internet connection at work, and I want to bring there a specific library.

So I want to be able to download at home an artifact along with all of its dependencies (recursively), in order to be able to take all of these jars and bring them to work.

I have read on this site about dependency:get , which is great but downloads the artifacts to the local Maven repo ( ~/.m2/repository ). This means that after downloading, I need to look at pom files and manually copy all of the dependent JAR files to some directory, which I can then bring to work.

I would love to have a way to simply download the desired JAR and all of its dependencies into a specific folder.

Is there a way to acheive this?

Please note: this question is different than the mentioned duplicate, in that I'm asking how to do this without any project or pom.xml file. I'm looking for the simplest way to do this.

EDIT : I believe I found a possible solution (not the most elegant though..):

  1. Rename the local repo ( ~\\.m2\\repository on my Windows machine) to repository.old . Create an empty directory repository at the same location instead.

  2. Run

    mvn dependency:get -Dartifact=<groupid>:<artifactid>:<version>

    This doesn't require a pom.xml or a project.

  3. The artifact and dependencies have been downloaded to your local previously-empty repository ( ~\\.m2\\repository ).

  4. Move the local repository to wherever, and rename repository.old back to repository .

(I think) you now have all the dependencies for your desired artifact.

dependency:get will load everything you need in .m2 then when you are offline you will be good. I don't think you need to do anything else.

Test it by disconnecting your machine for your network when you are at home.

Normally the dependencies are downloaded when maven is updating the indieces. As you can see in this post: What is Eclipse doing when it says that it's updating indexes? you just need to enable eclipse or whatever ide youre using to download the sources as well.

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