有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java使用maven使插件中止构建过程

我已经编写了一个maven插件,在某些情况下会抛出

MojoExecutionException

如果抛出这样的异常,我希望我的插件中止构建过程。有没有办法做到这一点


共 (1) 个答案

  1. # 1 楼答案

    doc开始:

    The execute method can throw two exceptions:

    • org.apache.maven.plugin.MojoExecutionException if an unexpected problem occurs. Throwing this exception causes a "BUILD ERROR" message to be displayed.
    • org.apache.maven.plugin.MojoFailureException if an expected problem (such as a compilation failure) occurs. Throwing this exception causes a "BUILD FAILURE" message to be displayed.

    因此,您必须更改抛出的异常