创建一个封闭的Maven构建 [英] Create an hermetic Maven build

查看:123
本文介绍了创建一个封闭的Maven构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在准备一个可能没有互联网连接的研讨会.因此,我想提供项目的每个依赖项/插件,以便与会者可以完全离线地进行处理.

I'm preparing a workshop where they may be no Internet connection. Because of that, I'd like to provide every dependency/plugin of the project, so attendees can work on it, completely offline.

我有一个基本的Maven项目,其中包含一些依赖项和两个插件.

I've got a basic Maven project with some dependencies and two plugins.

首先,我创建了一个备用本地存储库:

First, I created an alternate local repository:

mvn -Dmaven.repo.local=dependencies dependency:go-offline

然后,我希望以下命令可以正常运行,但事实并非如此!而且我提到了一些缺少的插件,这些插件在Maven Central或Maven发行版中均不可用:

Then, I expected the following command to run fine, but it doesn't! And I some mentioned missing plugins are not available in maven central or within the maven distribution:

mvn -o -Dmaven.repo.local=dependencies package

此操作失败,并显示以下错误消息:

This fail with the following error message:

[错误]无法在项目XXX上执行目标org.apache.maven.plugins:maven-resources-plugin:2.6:resources(默认资源):执行目标org.apache.maven.plugins的默认资源: maven-resources-plugin:2.6:resources失败:插件org.apache.maven.plugins:maven-resources-plugin:2.6或其依赖项之一无法解析:以下工件无法解析:org.apache.maven :maven-profile:jar:2.0.6,org.apache.maven:maven-repository-metadata:jar:2.0.6,org.apache.maven:maven-plugin-registry:jar:2.0.6,classworlds:classworlds :jar:1.1-alpha-2:无法访问中央( https://repo.maven.apache.org /maven2 )处于离线模式,并且之前从未从其下载工件org.apache.maven:maven-profile:jar:2.0.6.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project XXX: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources failed: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven:maven-profile:jar:2.0.6, org.apache.maven:maven-repository-metadata:jar:2.0.6, org.apache.maven:maven-plugin-registry:jar:2.0.6, classworlds:classworlds:jar:1.1-alpha-2: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven:maven-profile:jar:2.0.6 has not been downloaded from it before.

有什么想法在创建备用本地存储库时如何获取这些丢失的位?预先感谢!

Any idea how to get these missing bits while creating an alternate local repo? Thanks in advance!

推荐答案

基于

Based on this issue in the plugin's Jira this problem is still not resolved. The best work around so far is to package the project online once, using the custom repository.

mvn -Dmaven.repo.local=dependencies dependency:go-offline

然后

mvn -Dmaven.repo.local=dependencies package

最后

mvn -Dmaven.repo.local=dependencies -o package

如果您的研讨会要比部署更深入,则应检查下一个目标是否也能在离线状态下正常运行!

If your workshop go farther than deploy, you should check that next goals run fine offline too!

这篇关于创建一个封闭的Maven构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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