Enable Gradle Daemon

I have a gradle-based build that executes gradle several times. It would speed things up significantly if gradle was able to use the gradle daemon.

However, even if I start the daemon manually with ./gradlew --daemon, circleci seems to kill it before executing the next command, and thus it has no effect whatsoever (except slowing down the build).

Is there a way to keep the daemon running while the build executes?

1 Like

Figured out a solution:

dependencies:
  pre:
    - TERM=dumb ./gradlew --foreground:
        background: true
    - until (./gradlew --status | grep -q IDLE); do echo "Waiting for Gradle daemon..."; done

Also make sure the environment is set to pass the same options to the daemon as to the client processes e.g.:

machine:
  environment:
    _JAVA_OPTIONS: "-Xms1024m -Xmx2048m"
    GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xms1024m -Xmx2048m"'
1 Like