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 above sorts of 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 following scenarios:
In general, snappy behavior of the build tool is always handy. If you try using the daemon for your local builds it's going to be hard for you to go back to regular use of Gradle.
The Tooling API (see Chapter 57, Embedding Gradle) uses the daemon all the time, e.g. you cannot officially use the Tooling API without the daemon. This means that if you use the STS Gradle plugin for Eclipse or new Intellij IDEA plugin (IDEA>10) the daemon acts behind the hood.
In future the daemon will offer more features:
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 new daemon process is forked read the dedicated section below. The daemon process automatically expire after 3 hours of idle time.
Here're all situations in which we fork a new daemon process:
--stopcommand line instruction: You can only stop daemons that were started with the Gradle version you use when running
We plan to improve the ways of managing / pooling the daemons in future.
For command line usage take a look 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”. The 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”