Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pre-download all dependencies

Tags:

java

maven

I need to release our Maven build Java project to an remote QA team. For this I would like to download all the dependencies, and send them so they do not need to download them.

Currently all dependencies are defined in the pom.xml file, and we use either mvn install or mvn package to build the project. Some of the project members use uber jars, others use jars + dependencies to do execution.

What would be the easiest way to pre-package the dependent jar files so that there is no download from the internet, and does not change our current build process too much?

like image 802
tsar2512 Avatar asked Mar 11 '16 16:03

tsar2512


People also ask

How do I re download all Maven dependencies in eclipse?

In Maven, you can use Apache Maven Dependency Plugin, goal dependency:purge-local-repository to remove the project dependencies from the local repository, and re-download it again.

Where does POM XML download dependencies?

If you build your project using the minimal POM, it would inherit the repositories configuration in the Super POM. Therefore when Maven sees the dependencies in the minimal POM, it would know that these dependencies will be downloaded from https://repo.maven.apache.org/maven2 which was specified in the Super POM.

How do I download Maven dependencies?

Via the Maven index, you can search for dependencies, select them and add them to your pom file. To download the index, select Windows > Preferences > Maven and enable the Download repository index updates on startup option. After changing this setting, restart Eclipse. This triggers the download of the Maven index.


2 Answers

A possible solution would be to purge your local repository, tell Maven to download every dependencies and plugin dependencies of your project and make a ZIP of that.

To purge your local repository, you can simply delete the folder {user.home}/.m2/repository. Then, you can use the dependency:go-offline goal:

Goal that resolves all project dependencies, including plugins and reports and their dependencies.

mvn dependency:go-offline

This will download everything that your project depends on and will make sure that on a later build, nothing will be downloaded.

Then, you can simply make a ZIP of {user.home}/.m2/repository and send that to your Q/A team. They will need to unzip it inside their own {user.home}/.m2/repository to be able to build the project.

like image 196
Tunaki Avatar answered Oct 11 '22 22:10

Tunaki


Offline Package deploy

Your requirement can be accomplished by creating a stand alone jar file with full dependencies. You can port it anywhere please refer https://stackoverflow.com/a/35359756/5678086

  1. Build a full dependency JAR file as said in the answer
  2. Copy the JAR to the destination machine you want
  3. Run the below command from there

    mvn install:install-file -Dfile=<path-to-file>
    

This will install the dependecies in the maven repository of the destination machine. This is fully offline

like image 33
Thanga Avatar answered Oct 11 '22 21:10

Thanga