Maven强制实施器插件丢失或规则无效 [英] Maven enforcer plugin missing or invalid rules
问题描述
我正在尝试为maven设置执行程序插件,以执行最低Java版本.但是,每当我尝试运行mvn enforcer:enforce
时,我都会得到:
I am trying to setup the enforcer plugin for maven to enforce a minimum Java version. However, whenever I try to run mvn enforcer:enforce
, I get:
目标org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce的参数规则"丢失或无效
The parameters 'rules' for goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce are missing or invalid
这是我pom文件的相关部分:
Here is the relevant portion of my pom file:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce-java</id>
<phase>validate</phase>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>(1.7.0-20,)</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
我还尝试用<alwaysPass/>
替换<requireJavaVersion>
块,以防某些无效,但仍然失败,并出现相同的错误.
I also tried replacing the <requireJavaVersion>
block with <alwaysPass/>
, in case something was invalid, but it still failed with the same error.
推荐答案
可能是您使用了无效的规则名称.查看规则页面. 规则名称区分大小写. 虽然这里不是这种情况.
It may be that you are using invalid rule names. Check out the rules page. The rule names are case sensitive. Though this is not the case here.
----编辑----
---- Edit ----
请注意,POM配置的执行ID为enforce-java
,并且执行绑定到生命周期的validate
阶段.命令mvn enforcer:enforce
正在运行目标,而不是生命周期中的某个阶段.您在POM中提供的配置不适用于enforcer:enforce
目标.
Note that the POM configuration has an execution ID of enforce-java
and that execution is bound to the validate
phase of the lifecycle. The command mvn enforcer:enforce
is running a goal, not a phase in the lifecycle. The configuration you provided in the POM doesn't apply to the enforcer:enforce
goal.
有两种方法可以使这项工作.您选择哪种取决于您的需求.
There are two ways to make this work. Which one you choose depends on what you need.
- 如果您只是尝试在不运行整个构建的情况下测试强制实施程序插件配置,请运行
mvn validate
. - 如果要求
mvn enforcer:enforce
有效,则将执行ID更改为default-cli
.
- If you are just trying to test the enforcer plugin configuration without running the whole build, run
mvn validate
. - If the requirement is that
mvn enforcer:enforce
works, then change the execution ID todefault-cli
.
这篇关于Maven强制实施器插件丢失或规则无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!