Maven preloads all dependencies

I need to issue a maven build java project for a remote QA command. To do this, I would like to download all the dependencies and send them so that they do not download them.

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

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

+6
source share
2 answers

A possible solution is to clean up your local repository, tell Maven to download all the dependencies and dependencies of the plugin on your project and make it ZIP.

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

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

 mvn dependency:go-offline 

This will download everything your project depends on, and make sure that nothing will be loaded during subsequent builds.

Then you can simply create a ZIP {user.home}/.m2/repository and send it to the Q / A team. They will need to unzip it in their own {user.home}/.m2/repository in order to be able to create the project.

+12
source

Standalone Package Deployment

Your requirement can be met by creating a separate jar file with full dependencies. You can send it anywhere, please contact fooobar.com/questions/2346 / ...

  • Create a full dependency JAR file as said in the answer
  • Copy the JAR to the desired computer.
  • Run the command below

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

This will install the dependencies in the maven repository of the destination computer. It is completely autonomous

+1
source

All Articles