Maven预下载所有依赖项 [英] Maven pre-download all dependencies

查看:129
本文介绍了Maven预下载所有依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将我们的maven构建Java项目发布给远程质量检查团队.为此,我想下载所有依赖项并发送给他们,这样他们就不需要下载它们了.

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.

当前,所有依赖项都在pom.xml文件中定义,并且我们使用mvn install或mvn包来构建项目.一些项目成员使用uber jars,其他一些项目则使用jars +依赖项来执行.

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.

最简单的方法是将相关的jar文件预先打包,以免从互联网上下载文件,并且不会对当前的构建过程造成太大的改变?

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?

推荐答案

一种可能的解决方案是清除本地存储库,告诉Maven下载项目的每个依赖项和插件依赖项,并为其做一个ZIP.

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.

要清除本地存储库,只需删除文件夹{user.home}/.m2/repository.然后,您可以使用 dependency:go-offline 目标:

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.

然后,您只需将ZIP制成{user.home}/.m2/repository并将其发送给Q/A团队.他们需要将其解压缩到自己的{user.home}/.m2/repository中,才能构建项目.

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.

这篇关于Maven预下载所有依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆