有没有办法使Maven构建独立于网络连接? [英] Is there a way to make the Maven build independent of the network connection?

查看:247
本文介绍了有没有办法使Maven构建独立于网络连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在持续集成环境中工作,自动构建过程的一部分包括Maven托管项目的编译。

I'm working in a Continuous Integration environment and part of the automated build process includes the compilation of Maven managed projects.

我想知道的是,是一种使Maven构建独立于网络连接的方式。

What I want to know is if there is a way to make the Maven build independent of the network connection.

目前我们拥有所有需要在存储库中安装的jar,但问题是Maven尝试检查插件更新,如果最后

Currently we have the all the jar's that we need installed in the repository but the problem is that Maven tries to check for plugins updates and that makes the build fail if, eventually, the connection is down.

推荐答案

您可以使用-o开关离线运行,也可以添加< offline> ; true< offline> 到您的settings.xml。

You can either run offline with the -o switch or by adding <offline>true<offline> to your settings.xml.

值得指出的是,如果Maven决定需要检查依赖关系或插件更新,那么当运行离线时Maven可能会失败。如果您使用< updatePolicy>从不< / updatePolicy>设置存储库,您可以避免这种情况,但您需要定期强制更新(使用-U和/或-cpu)。

It's worth pointing out though that Maven may fail the build when running offline if it decides it needs to check for dependency or plugin updates. If you set your repositories with <updatePolicy>never</updatePolicy> you can avoid this, but you'll need to force updates periodically (with -U and/or -cpu).

如果您使用的是存储库管理器,将您的存储库设置为外部存储库的镜像。这仍然涉及网络连接,但只有您的内部网络(或如果存储库管理器在您的本地计算机上,没有连接)。

If you are using a repository manager, you can set your repository to be a mirror of the external repositories. This still involves a network connection, but only your internal network (or if the repository manager is on your local machine, no connection at all).

所有对我的本地 Nexus 服务器的中央呼叫都在我的开发盒上运行:

For example this config redirects all calls to central to my local Nexus server running on my development box:

<mirrors>
  <mirror>
    <id>central-proxy</id>
    <mirrorOf>central</mirrorOf>
    <url>http://localhost/nexus/content/groups/public</url>
  </mirror>
</mirrors>

这篇关于有没有办法使Maven构建独立于网络连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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