Is there a way to make the Maven build independent of the network connection?

流过昼夜 提交于 2019-12-05 21:04:28

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

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).

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>

use the -o (offline) option

You can try installing a "Build Artifact Repository Manager" like Archiva (http://archiva.apache.org/) in you local network. It will work as a mirror, so maven will try to download and check for updates on your local network and not over internet. Uou should also build your own artifacts and use it on archiva.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!