gradle --no-daemon: One-Shot Builds for CI
gradle --no-daemon runs the build in a throwaway JVM that terminates when the build finishes, leaving no lingering daemon on the runner.
On ephemeral CI runners a persistent daemon gives no benefit and can leak memory across jobs. --no-daemon is the conventional CI setting.
What it does
Normally Gradle starts a background daemon JVM that survives between builds for warm-start speed. --no-daemon runs the build directly in a single-use JVM that exits afterward, so nothing is left running. This trades a slower start for a clean, predictable process lifecycle.
Common usage
./gradlew build --no-daemon
# or set it for all invocations in the environment
export GRADLE_OPTS="-Dorg.gradle.daemon=false"
./gradlew buildFlags
| Flag / property | What it does |
|---|---|
| --no-daemon | Run a single-use JVM that exits after the build |
| -Dorg.gradle.daemon=false | Same, via system property |
| org.gradle.daemon=false | Disable the daemon by default (gradle.properties) |
| --stop | Stop any running daemons (separate command) |
In CI
Use --no-daemon (or org.gradle.daemon=false) on hosted runners so each job starts clean and memory is not carried over. On long-lived self-hosted runners a daemon can help, but cap its heap. Either way, cache ~/.gradle/caches so the JVM cold start does not also re-download dependencies.
Common errors in CI
"Gradle daemon disappeared unexpectedly (it may have been killed or may have crashed)" appears with the default daemon when the runner OOM-kills it; --no-daemon plus a heap bump avoids the confusing message. "To honour the JVM settings for this build a single-use daemon process will be forked" is informational: a daemon could not match the requested JVM args, so Gradle forked a one-off.