MojoExecutionException不会停止maven编译过程

时间:2015-07-22 03:06:39

标签: java maven maven-plugin

我制作了一个Maven插件。问题是即使抛出MojoExecutionException(或MojoFailureException)也不会停止构建过程! 是否需要任何其他配置?

@Mojo( name = "something")
public class CoffeescriptMojo extends AbstractMojo {

    public void execute() throws MojoExecutionException, MojoFailureException {
        new MojoExecutionException("Error not raise!");
    }
}

用法:

<groupId>my.sample</groupId>
<artifactId>sample</artifactId>
<version>1.1-SNAPSHOT</version>
<executions>
    <execution>
        <phase>compile</phase>
        <goals>
            <goal>something</goal>
        </goals>
    </execution>
</executions>

1 个答案:

答案 0 :(得分:0)

非常愚蠢的错误。我忘了在开头添加throw。感谢新的Intellij代码警告,我找到了它!

new MojoExecutionException("Error not raise!");

必须是:

throw new MojoExecutionException("Error not raise!");