Gradle Javadoc GWT 错误 - 无法访问导入中的事件 com.google.gwt.user.client.Event

Gradle Javadoc GWT Error - cannot access Event in import com.google.gwt.user.client.Event

我正在尝试使用 gradle 生成 GWT Java 项目的 javadoc。当我运行任务gradlebuild时,编译成功。但是,当我 运行 gradle javadoc 任务时,它失败并出现以下错误:

C:\Users\jbraga.gradle\caches\modules-2\files-2.1\com.google.gwt\gwt-user.8.1a13fbee70848f1f1cddd3ae33ad180af3392d9e\gwt-user-2.8.1.jar(com/google/gwt/user/client/ui/Widget.java):28: error: cannot access Event import com.google.gwt.user.client.Event; ^ bad source file: C:\Users\jbraga.gradle\caches\modules-2\files-2.1\com.google.gwt\gwt-user.8.1a13fbee70848f1f1cddd3ae33ad180af3392d9e\gwt-user-2.8.1.jar(com/google/gwt/user/client/Event.java) file does not contain class com.google.gwt.user.client.Event Please remove or make sure it appears in the correct subdirectory of the sourcepath. C:\Users\jbraga.gradle\caches\modules-2\files-2.1\com.google.gwt\gwt-user.8.1a13fbee70848f1f1cddd3ae33ad180af3392d9e\gwt-user-2.8.1.jar(com/google/gwt/layout/client/Layout.java):18: error: cannot find symbol import static com.google.gwt.dom.client.Style.Unit.PX; ^ symbol: static PX location: class

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':javadoc'. Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): 'C:\Users\jbraga\odsoft-18-19-nmb-g302\odsoft\exercise1\component1\students\build\tmp\javadoc\javadoc.options'

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 4s

我使用的 GWT 版本是 2.8.1,2.8.2 也是如此。 gradle.properties 文件指定了 SDK 的正确路径。

有人能解决这个问题吗?

提前致谢。

这是一个已知的 Gradle 问题:https://github.com/gradle/gradle/issues/5630,幸运的是有一个已知的解决方法:

javadoc {
  options.addStringOption("sourcepath", "")
}

对我来说,对 Thomas Broyer 建议的解决方法稍加修改就奏效了:

javadoc {
  options.addStringOption("sourcepath", "")
}