I have a complex set of projects built by Gradle 4.10.3. I can build them from the command line, but I can also import them to IntelliJ 2018.3 Ultimate without major issues.
When I upgrade my Gradle to 5.1.1, the projects are still building fine from the console, however I can no longer import (or refresh) the project in IntelliJ 🙁
The configuration part goes fine, but the daemon process could not be started within IntelliJ. If I set Gradle JVM to Java 8 in the IntelliJ project settings, I get an error:
Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. Unrecognized option: --add-opens
If I set Gradle JVM to Java 11 in the IntelliJ project settings, I get a different error:
Error: Could not find or load main class java.base.java.lang=ALL-UNNAMED Caused by: java.lang.ClassNotFoundException: java.base.java.lang=ALL-UNNAMED
As soon as I execute gradlew wrapper --gradle-version=4.10.3
(change back the wrapper to 4.10.3), the IntelliJ plugin works fine again.
If I add gradle idea task (idea gradle plugin) to the scripts, it executes fine from the console also with the version 5.1.1.
Removing .idea settings from the user folder did not help. Clean import did not help either. All possible settings inside IntelliJ related to Gradle (including all wrapper-related settings) are tried. Nothing helped 🙁
The problem seems to be so trivial, however I cannot find a solution since few days 🙁 Where those --add-opens
are coming from? How to prevent this?
Advertisement
Answer
The cause was the gradle.properties
file in the .gradle
folder in the user home. Just removing the file solves this problem with IntelliJ.
Still it would be nice to know the cause of this…
Very weird bug!
Credits: IntelliJ IDEA Gradle sync: Problem with setting Gradle’s Java home to some JDKs