java 错误:BUG!源单元“_BuildScript_”中的“类生成”阶段中的异常不受支持的目标模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45899027/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 08:58:33  来源:igfitidea点击:

Error:BUG! exception in phase 'class generation' in source unit '_BuildScript_' unsupported Target MODULE

javaintellij-ideagradlejava-9

提问by Micha? Szewczyk

I'm trying to create a new Java 9project using gradlebut right after project creation I received error from gradle:

我正在尝试使用gradle创建一个新的Java 9项目,但在项目创建后,我收到了来自 gradle 的错误:

Error:BUG! exception in phase 'class generation' in source unit '_BuildScript_' unsupported Target MODULE

Java version: 9 (build 9+178)
Gradle version: 4.1-rc-2

Java 版本:9(构建 9+178)
Gradle 版本:4.1-rc-2

According to thisarticle those java/gradle versions should be compatible.
How can I solve this problem?

Any help highly appreciated.

根据这篇文章,那些 java/gradle 版本应该是兼容的。
我怎么解决这个问题?

任何帮助高度赞赏。

采纳答案by kamaz

I have solved it by downgrading Gradle JVM to 8. It is not perfect but keeps you going while jdk9 and gradle and intellij stabilises.

我已经通过将 Gradle JVM 降级到 8 解决了这个问题。它并不完美,但在 jdk9 和 gradle 以及 Intellij 稳定的同时让你继续前进。

Intellij View

智能视图

回答by Narendran Solai Sridharan

Setting the Gradle home to local Gradle distribution solved the issue in my case.

将 Gradle home 设置为本地 Gradle 发行版解决了我的问题。

  • Java version: 9+181
  • Gradle version: 4.1
  • Intellij version: 2017.2.2
  • Java版:9+181
  • 摇篮版本:4.1
  • Intellij 版本:2017.2.2

if we set to use default Gradle wrapper, IntelliJ downloads an earlier version of Gradle. I think it is the reason for failure.

如果我们设置为使用默认 Gradle 包装器,IntelliJ 会下载早期版本的 Gradle。我认为这是失败的原因。

enter image description here

在此处输入图片说明

回答by Sormuras

Seems fixed in 2017.3

似乎已在 2017.3 中修复

See IntelliJ IDEA 2017.3 173.2941.3 Release Notes: https://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+2017.3+173.2941.3+Release+Notes

参见 IntelliJ IDEA 2017.3 173.2941.3 发行说明:https://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+2017.3+173.2941.3+Release+Notes

See issue: https://youtrack.jetbrains.com/issue/IDEA-171520

请参阅问题:https: //youtrack.jetbrains.com/issue/IDEA-171520