The Gradle daemon (sometimes referred as the build daemon) aims to improve the startup and execution time of Gradle.
We came up with several use cases where the daemon is very useful. For some workflows, the user invokes Gradle many times to execute a small number of relatively quick tasks. For example:
gradle tasksis executed a number of times.
For these workflows, it is important that the startup cost of invoking Gradle is as small as possible.
In addition, user interfaces can provide some interesting features if the Gradle model can be built relatively quickly. For example, the daemon might be useful for the following scenarios:
In general, snappy behavior of the build tool is always handy. If you try using the daemon for your local builds, you won't want to go back.
The Tooling API (see Chapter 63, Embedding Gradle) uses the daemon all the time, e.g. you cannot officially use the Tooling API without the daemon. This means that whenever you are using the STS Gradle plugin for Eclipse or the Gradle support in Intellij IDEA, you're already using the Gradle Daemon.
In the future, there are plans for more features in the daemon:
The basic idea is that the Gradle command forks a daemon process, which performs the actual build. Subsequent invocations of the Gradle command will reuse the daemon, avoiding the startup costs. Sometimes we cannot use an existing daemon because it is busy or its Java version or jvm arguments are different. For exact details on when exactly a new daemon process is forked read the dedicated section below. The daemon process automatically expires after 3 hours of idle time.
Here are all situations in which we fork a new daemon process:
--stopcommand line instruction: this command will only stop daemons that were started with Gradle version that is executing
We plan to improve the functionality of managing and pooling the daemons in the future.
For command line usage, look at the dedicated section in Appendix D, Gradle Command Line. If you are tired of using the same command line options again and again, take a look at Section 20.1, “Configuring the build environment via gradle.properties”. This section contains information on how to configure certain behavior of the daemon (including turning on the daemon by default) in a more 'persistent' way.
Some ways of troubleshooting the Gradle daemon:
--stopcommand line option or in a more forceful way.
--foregroundmode to observe how the build is executed.
Some daemon settings, such as JVM arguments, memory settings or the Java home, can be configured. Please find more information in Section 20.1, “Configuring the build environment via gradle.properties”