34

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.

Michał Szewczyk
  • 7,540
  • 8
  • 35
  • 47

4 Answers4

23

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

kamaz
  • 394
  • 1
  • 9
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

  • 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 – oidualc Sep 17 '17 at 06:44
  • 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. – Narendran Solai Sridharan Sep 17 '17 at 15:28
  • Yes, for the moment I'm doing this – oidualc Sep 17 '17 at 19:33
  • Didn't work for me too. Went back to JDK8 (with Gradle 4.1) which works fine. Will wait some days – dominic.e Sep 20 '17 at 11:56
  • 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. – Erik Oct 12 '17 at 16:49
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

Sormuras
  • 8,491
  • 1
  • 38
  • 64
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.

dB.
  • 4,700
  • 2
  • 46
  • 51