为什么 GWT 编译错误不会破坏 Maven 构建?

Why does GWT compile errors won't break the maven build?

我正在使用 gwt-maven-plugin 在 maven 中构建一个 GWT 项目。

最近我注意到 class 上的一个错误,其中在客户端 class 上调用了一些服务器代码。一开始以为gwt编译有问题(不包括这个class)。但后来我注意到它正在编译 class 并且它在信息日志级别上抛出错误。

[INFO]    Tracing compile failure path for type 'com.mycompany.shared.IElement'
[INFO]       Errors in 'jar:file:/Users/myuser/.m2/repository/com/mycompany/package/package-java/1.0.0-SNAPSHOT/package-java-1.0.0-SNAPSHOT-sources.jar!/com/mycompany/shared/IElement.java'
[INFO]          Line 45: No source code is available for type com.mycompany.test.Tester; did you forget to inherit a required module?

为什么这只是一个信息日志? 为什么这不会破坏构建? 我可以强制构建中断这种错误吗?

是的,你可以,事实上你应该!甚至有可能此选项将来会默认启用,因为这些类型的 'recoverable' 错误会导致编译器出现性能问题,因为它会不断恢复并解决丢失的代码。

使用 maven 插件,您可以简单地将此标志设置为 true。来自 http://mojo.codehaus.org/gwt-maven-plugin/compile-mojo.html#failOnError

failOnError:

Fail compilation if any input file contains an error. Can be set from command line using '-Dgwt.compiler.strict=true'.

在您的插件的 <configuration> 块中,这看起来像

<failOnError>true</failOnError>

(这曾经被称为 <strict>,在我自己的一些 pom 文件中,仍然是这样...)