问题标签 [maven-enforcer-plugin]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
266 浏览

maven - Maven:如果构建失败

我想在发布工件之前进行一些自动检查。如果出现以下情况,则构建失败:

  • 存在较新版本的依赖项
  • 覆盖依赖管理版本
  • 使用的依赖项不在白名单中
  • 重复声明的依赖项(如手动依赖项:analyze-duplicate)

版本 maven 插件是手动解决方案。

Maven 执行器似乎是一个有效的解决方案(如果存储库中存在更新版本的依赖项,如何使 Maven 构建失败?

标准规则不起作用。

在考虑编写地雷之前,我正在寻找更多的执行者规则。找到这些:

还有更多吗?

0 投票
1 回答
1021 浏览

maven - maven-enforcer-plugin complains about dependencies that I cannot find in pom.xml files

I am encountering a problem with the maven-enforcer-plugin. It is complaining with the following (simplified) output:

The problem is with some_sub_part_BB:1.1.0. According to the plugin, this part has a dependency on version 1.0.4 of the interfaces. But this is not possible: version 1.0.0 of some_sub_part_BB used interfaces version 1.0.3, and version 1.1.0 of some_sub_part_BB went directly to using interfaces version 1.0.6. I do not have any artifacts of some_sub_part_BB that uses version 1.0.4.

I guess I'm looking at some bug of the plugin, but I would like to debug this issue to make sure what is going wrong. Is this an issue anyone has encountered before, or can someone provide me any pointers on how to debug this problem? (I am fairly new to Maven, and aside from checking all the pom.xml files I have no idea where to look further).


Side note: The idea is (was) that the interface version to be used is specified on the project level POM, so that all (sub-) parts agree on which interface to use. However, as you can see, the different parts also specify which interface they use, which I don't think is the correct way of doing this. I haven't figured out how to fix this (yet).

0 投票
3 回答
2246 浏览

maven - eclipse maven项目中的声纳插件错误

我正在使用 Maven 项目在 Eclipse 中为sonarqube创建一个新的语言插件,并且在构建项目时遇到以下错误:

0 投票
3 回答
26821 浏览

java - Maven 强制插件缺少或无效规则

我正在尝试为 maven 设置强制插件以强制执行最低 Java 版本。但是,每当我尝试运行时mvn enforcer:enforce,我都会得到:

目标 org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce 的参数“规则”丢失或无效

这是我的 pom 文件的相关部分:

我还尝试用 替换<requireJavaVersion><alwaysPass/>,以防某些内容无效,但它仍然失败并出现相同的错误。

0 投票
1 回答
1046 浏览

java - 如何在 Maven 发布准备更改 pom.xml 之前运行 Maven 强制执行规则?

我创建了一个自定义 Maven 强制执行规则。此规则将检查<scm><connection>值的内容以确保它指向trunkbranches/*(即不是标记)。该执行器的配置pom.xml如下:

不幸的是,当我们将它与 Maven Release 插件一起使用时,后者插件会<scm><connection>在 [enter link description here] prepare2目标期间更改值的内容,因此在有效调用执行器之前。这导致我的自定义规则失败,因为此时<scm><connection>指向标签。

所以我的问题是:有没有办法在 Maven 发布插件开始修改之前强制调用执行器pom.xml

ps:Jenkins作业分为2个步骤:mvn clean release:preparemvn release:perform.

0 投票
0 回答
264 浏览

maven - 如何使用 Maven 执行器插件检测 *独立* 项目之间的依赖收敛冲突

当使用 maven enforcer plugin运行依赖收敛时,我们可以很容易地检测到某个项目可传递地依赖于同一工件的 2 个不同版本。

但是考虑为同一系统编写插件的一大群人。并考虑该组中的 2 个团队。

一个团队正在开发插件 A 并具有以下依赖链:A -> B -> C (v 1.1)

另一个团队开发插件 X 并具有以下依赖链:X -> Y -> C (v 2.0)

项目 A 和 X 是完全独立的,但在生产中,两个插件都已部署并且存在冲突。尽管两个团队共享 CI,但强制插件不会检测到这种冲突,因为只有当它们共享一个共同的祖先时才会检测到冲突。

(例如,如果 A 也有:A -> D -> C (v 1.4),这将被检测到)。

似乎解决方案是定义第三个“超级模块”,它将聚合 A 和 X 并将其提供给执行器插件。我遇到了这个问题:

我定义了这样一个模块。添加了 A 和 X 作为依赖项('pom' 类型),但是当我执行执行器时,它没有检测到冲突!就好像超级 pom 无法“吸收”传递依赖。

我在这里想念什么?

我正在使用 Maven 3.0.4。


更具体的说明:

此链接包含 2 个独立项目。一个依赖于org.opensaml:opensaml:2.2.0,另一个依赖于org.apache.solr:solr-core:4.10.0。麻烦的是前者依赖于commons-lang:commons-lang:2.1而后者依赖于commons-lang:commons-lang:2.6

因此,这两个 jar 都出现在最终应用程序的类路径中,这有可能破坏任何一个依赖项。

我尝试创建另一个聚合两个 'roots' 的项目,但强制插件没有检测到冲突。

这是我正在使用的命令行:mvn enforcer:enforce validate

0 投票
1 回答
2221 浏览

maven - Maven 执法者是否忽略依赖管理部分?

我在父 pom 的导入的 dependencyManagement 部分中指定了一个库版本。我确认我的有效 pom 只有一次出现这种依赖。它在依赖管理部分:

这应该根据它覆盖传递依赖项的版本。安装(并重新安装依赖项以匹配版本边界)后,org.apache.maven.plugins:maven-dependency-plugin:2.8:tree 打印:

但是(最初,没有重新安装依赖项)enforcer 抱怨错误的版本:

并表明第一个传递依赖使用

这来自依赖,而依赖又依赖于:

和其他用途

为什么执行器与依赖树不一致?有什么问题?如果我使用版本限制,它们是否会受到尊重,我可以跳过为此目的使用强制执行器吗?

此外,向相关项目模块添加依赖项不会改变任何内容。

0 投票
2 回答
1314 浏览

maven - Maven:如何允许某个操作系统进行构建?

我知道我可以maven-enforcer-plugin像这样要求特定的操作系统系列:

但是我可以定义多个可用于构建的操作系统(例如 Unix 和 Windows)吗?

找不到任何直接的方法来做到这一点,所以我很感激任何解决方法。

0 投票
3 回答
5795 浏览

java - 版本:display-plugin-updates 不理解 maven-enforcer-plugin

所以,我正在尝试使用一些插件的最新版本。早些时候我使用了先决条件标签,但很多资源(示例)说它应该被视为已弃用,应该使用 maven-enforcer-plugin 代替。这是我的配置:

但是,当我运行mvn versions:display-plugin-updates时,我仍然会收到以下文本:

改为使用先决条件标签。

0 投票
1 回答
1891 浏览

maven - Gradle 相当于 Maven Enforcer 的 RequireReleaseDeps

Gradle 相当于使用 Maven Enforcer 插件来防止发布指向快照依赖项是什么?这可能吗?

如果构建有任何快照依赖项,我希望能够防止发布发生。我知道我可能可以通过它编写自己的方式,但我想知道是否有任何“标准”或明显的方式使用 gradle 来实现它,我在网上找不到任何关于它的信息。

解决方案

使用正确答案建议的解决策略: