41

I need to disable the Gradle daemon in IntelliJ Idea, because somehow Scala plugin is not working with the daemon (the compilation fails with NullPointerException). I have tried to edit my IntelliJ Gradle build configurations to include a JVM system parameter -Dorg.gradle.daemon=false:

enter image description here

Also I've tried to use --no-daemon flag at the same place (Script parameters and VM options). Also I've tried to specify these options in the Preferences -> Gradle menu of IntelliJ. None of these attempts gave any result, the daemon continue to start, so I have to kill it before running/compiling for the second time.

enter image description here

Neither disabling daemon explicit in ~/.gradle/gradle.properties according to https://docs.gradle.org/current/userguide/gradle_daemon.html#N10473 doesn't have any effect.

How can I disable the Gradle daemon usage in IntelliJ Idea?

Will
  • 24,082
  • 14
  • 97
  • 108
Anatoliy Kmetyuk
  • 708
  • 1
  • 6
  • 10

4 Answers4

36

IntelliJ interacts with Gradle via the Gradle tooling API, which always uses the daemon. i.e. There is no way to turn it off.

What you could do (after filing a bug report) is not to use the IntelliJ Gradle integration but instead generate IntelliJ project files with

gradle idea

SkyWalker
  • 28,384
  • 14
  • 74
  • 132
Peter Niederwieser
  • 121,412
  • 21
  • 324
  • 259
  • "gradle idea" is needed only to generate the required files. Though the recent versions of Idea use "directory-based" project structure, so the file generation is no longer necessary. With or without file generation, from inside the Idea the project is run the same way. It is a pity that we don't have enough flexibility here. – Anatoliy Kmetyuk Aug 22 '14 at 19:30
  • 3
    `gradle idea` is still useful with the most recent IntelliJ versions (I use it all the time). "Not to use the IntelliJ Gradle integration" means not to use run configurations of type "Gradle", hence the project isn't run in the same way. Anyway, turning off the Gradle daemon is the wrong solution. Instead, try `tasks.withType(ScalaCompile) { scalaCompileOptions.fork = true }` or `tasks.withType(ScalaCompile) { scalaCompileOptions.useAnt = false }`, which will run Scala compilation in a separate process. – Peter Niederwieser Aug 23 '14 at 04:27
3

Because of lack of support of old libraries I moved a project from gradle to maven build management tool. But Intellij always wanted me to trigger a gradle changes import: additionally to "Maven project needs to be updated", there was also a "Gradle project needs to be updated" when I did changes to i.e. dependencies in pom.xml, with no integration of gradle in the project source files at all, no wrapper etc.

In my case I was able to get rid of Intellij bothering me with gradle by deleting the line <property name="settings.editor.selected.configurable" value="reference.settingsdialog.project.gradle" /> in .idea/workspace.xml and deleting the file .idea/gradle.xml in Intellij IDEA Ultimate 2019.2.

Jochen Haßfurter
  • 875
  • 2
  • 13
  • 27
1

I had a related problem and managed to disable the daemon through a config - I added org.gradle.daemon=false to a gradle.properties file in the project root folder. As explained here: Disabling Gradle daemon in a specific project.

Monde
  • 19
  • 1
  • 1
    does not work for me in IntelliJ 2022.2.3 and the property is greyed out as not existing – Uwe Post Oct 10 '22 at 10:32
  • 1
    @UwePost can confirm, the IDE ignores this property, while others are taken into effect. Running tasks via shell however will respect it. Not sure if this is intentional – Marian Klühspies Apr 30 '23 at 13:37
0

To disable the daemon for a single command (or a single IntelliJ run configuration), you can also pass org.gradle.daemon=false as a VM Option:

-Dorg.gradle.daemon=false
scottysseus
  • 1,922
  • 3
  • 25
  • 50