Maven执行器插件的用法 [英] usage of maven enforcer plugin

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

问题描述

我想使用Maven强制执行器插件检查我的路径上是否有重复的类.我已经从此处尝试了该示例.

I'd like to use the maven enforcer plugin to check to see if I have duplicate classes on my path. I've tried the example from here.

但是当我这样运行时:

mvn enforcer:enforce

我明白了:

无法执行目标 org.apache.maven.plugins:maven-enforcer-plugin:1.0.1:enforce (default-cli)在项目datapopulator上:参数'rules'用于 目标org.apache.maven.plugins:maven-enforcer-plugin:1.0.1:enforce是 丢失或无效

Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.0.1:enforce (default-cli) on project datapopulator: The parameters 'rules' for goal org.apache.maven.plugins:maven-enforcer-plugin:1.0.1:enforce are missing or invalid

有没有办法正确使用此功能?

Is there a way to use this correctly?

编辑#1

如果将我的配置更改为此:

If changing my config to this:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <version>1.0.1</version>
            <executions>
                <execution>
                    <id>enforce-versions</id>
                    <goals>
                        <goal>enforce</goal>
                    </goals>
                    <configuration>
                        <rules>
                            <AlwaysPass />
                        </rules>
                        <fail>true</fail>
                    </configuration>
                </execution>
            </executions>
        </plugin>

产生相同的错误.

推荐答案

您的第一个版本无法正常工作的原因是,执行标记内的插件配置与插件外的插件配置之间存在差异.执行标签.仅当您的插件由完整的Maven构建的特殊阶段触发时,才使用执行.

The reason why your first version did not work is because there is a difference between a plug-in configuration inside the execution tag and a plug-in configuration outside the execution tag. The execution is only used when your plug-in is triggered by a special phase of the complete Maven build.

Maven配置指南对其进行了更好的解释:

The Maven guide to configuration explains it better:

标记内部的配置与外部的不同,因为不能从直接命令行调用中使用它们.相反,仅当它们绑定到的生命周期阶段被调用时才应用它们.另外,如果将配置部分移到执行部分之外,它将全局应用于该插件的所有调用.

Configurations inside the tag differ from those that are outside in that they cannot be used from a direct command line invocation. Instead they are only applied when the lifecycle phase they are bound to are invoked. Alternatively, if you move a configuration section outside of the executions section, it will apply globally to all invocations of the plugin.

这篇关于Maven执行器插件的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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