使用 maven 插件执行器规则失败

Posted

技术标签:

【中文标题】使用 maven 插件执行器规则失败【英文标题】:Enforcer rules are getting failed using maven plugin 【发布时间】:2019-01-02 06:17:56 【问题描述】:

我的 pom.xml 带有以下包含强制规则的插件。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-enforcer-plugin</artifactId>
    <configuration>
        <rules>
            <banVersionDeps implementation="com.atlassian.maven.enforcer.BanVersionDeps">
                <bannedDependencyVersionRegexp>(?i)^.*-(rc|m)-?[0-9]+(-.+)?$</bannedDependencyVersionRegexp>
                <noFailReactorVersionRegexp>(?i)^.*-m-?[0-9]+(-.+)?$</noFailReactorVersionRegexp>
                <excludes>
                    <!-- Version being used is an RC with no newer GA release -->
                    <exclude>com.atlassian.crowd:*</exclude>
                    <exclude>net.fortuna.ical4j:ical4j</exclude>
                    <!-- Version being used is a milestone with no newer GA release -->
                    <exclude>com.atlassian.extension:*</exclude>
                    <exclude>com.atlassian.jira.plugins.inline-create:*</exclude>
                </excludes>
            </banVersionDeps>
        </rules>
    </configuration> 
</plugin>

当我开始使用这个 pom.xml 构建时,我面临以下错误。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce (enforce-versions) on project atlassian-jira-pageobjects: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce (enforce-versions) on project atlassian-jira-pageobjects: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.
    at org.apache.maven.plugins.enforcer.EnforceMojo.execute(EnforceMojo.java:237)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more

我正在使用apache-maven-3.2.5Java 8

谁能指导我这个配置有什么问题。

【问题讨论】:

正如错误消息所说,原因可能在日志前面的插件输出中列出:Look above for specific messages explaining why the rule failed. 是的,你是对的,因为我添加了排除规则及其工作...谢谢 【参考方案1】:

我遇到了 atlassian-browsers-windows 错误,我排除了该软件包并且它工作正常。

<excludes>
  <exclude>com.atlassian.browsers:atlassian-browsers-windows:*</exclude>
</excludes>

【讨论】:

以上是关于使用 maven 插件执行器规则失败的主要内容,如果未能解决你的问题,请参考以下文章

Maven SQL插件执行顺序

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

Maven 发布插件失败:源工件被部署两次

Maven 发布插件失败

如何在所有模块构建完成后执行maven插件

maven deploy 400失败,二次上传maven source.jar包