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

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

问题描述

我需要将我们的 Maven 构建 Java 项目发布给远程 QA 团队.为此,我想下载所有依赖项,然后发送它们,这样他们就不需要下载它们.

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 installmvn package 来构建项目.项目成员有的使用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-离线目标:

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.

然后,您可以简单地制作 {user.home}/.m2/repository 的 ZIP,并将其发送给您的问答团队.他们需要将其解压缩到自己的 {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.

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

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