35

I'm trying to create a new Java 9 project using gradle but right after project creation I received error from 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

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

Any help highly appreciated.

6
  • Can you share the Gradle event logs for this failure as well or/and a minimal project that can be tried out to reproduce this please. Commented Aug 27, 2017 at 3:07
  • what version of grade did you use? i used 4.1, still got the same error. Commented Aug 29, 2017 at 8:14
  • same version as you Commented Aug 29, 2017 at 8:16
  • I think 4.1 is not the release candidate version 4.1-rc-2 Commented Aug 29, 2017 at 9:48
  • Something similar happened for me, here is how I fixed it stackoverflow.com/a/53509014/1195507 Commented May 14, 2019 at 0:17

4 Answers 4

25

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.

Intellij View

Sign up to request clarification or add additional context in comments.

Comments

7

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

  • Java version: 9+181
  • Gradle version: 4.1
  • Intellij version: 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.

enter image description here

5 Comments

Any additional step to follow? In my case it isn't working with this configuration: jdk9+181, gradle 4.1, idea 2017.2.4, linux
I did not have any issues. since gradle is a build tool, you could try to downgrade JVM of build tool to 1.8 and give a try.
Yes, for the moment I'm doing this
Didn't work for me too. Went back to JDK8 (with Gradle 4.1) which works fine. Will wait some days
If on macOS and Gradle has been installed with Homebrew, then brew --prefix gradle reveals the location of where libexec/ can be found. For me, that is /usr/local/opt/gradle, so I set my project's Gradle home to /usr/local/opt/gradle/libexec. I'm sure Windows' alternative Chocolatey has a similar function to find the latest installation directory.
3

Seems fixed in 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

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

Comments

3

This issue seems to have been fixed in Groovy 2.4.12 and upgrading to at least that version resolved a similar problem in https://github.com/jenkinsci/JenkinsPipelineUnit/issues/292.

1 Comment

Upgrading groovy fixed the issue for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.