Points to Remember
- Gradle runs on JVM and several other dependencies.
- Gradle has to do boootstrap stuff whenever gradle is started.
- This startup process takes time and makes the build slower.
To overcome these points
gradle daemon was introduced.
What is a Gradle Daemon ?
Gradle daemon is a
long lived background background process that can be reused for building gradle
Gradle wrapper saves the time for starting a new gradle instance every time and
saves time required for bootstrapping and initialization.Such bootstrap tasks include
- Initialization of JVM
- Cache Project information
- Cache files , tasks
- Project structures etc
Gradle daemon is
configurable and can be switched on of off using
Also, gradle daemon
should be used only for development environments and not for production
environmnets. This is beacasue in production environments you want to build your projet independently
since it is more reliable.
Check the status of Gradle Daemon
To check the status of the gradle deamon you can use the command
The above command gives the following output. (A Gradle version can only connect to daemons of the same version.)
PID STATUS INFO
3461 IDLE 3.0
31881 BUSY 3.0
Only Daemons for the current Gradle version are displayed.
How to stop a Gradle daemon
To stop all running gradle daemon processess you can run the following command.
This will stop all the daemon processess that started with the same version of gradle that is used to execute the command.
States of a Gradle Daemon
A radle daemon can be in the following states.
idle- this is a gradle state that is running but is not doing any execution. This gradle daemon can be used for running new builds.
compatible- This is a gradle daemon that is compatible for running a gradle biuld.
Gradle build, firsts checks for an idle daemon with compatible configurations, if it exists, then the build is started using this daemon, if no such daemon exists then gradle will start a new gradle daemon for running the build.