Skip to content
Latchkey

gradle Command: Build JVM Projects in CI

gradle builds, tests, and packages JVM projects via a task-based DAG.

Gradle is a leading JVM build tool. In CI you typically call the wrapper (./gradlew) to pin the version, run the build/test tasks, and tune the daemon and cache for ephemeral runners.

Common flags

  • build / test / assemble - common lifecycle tasks
  • --no-daemon - do not start a background daemon (better for CI)
  • --build-cache - reuse outputs from the build cache
  • -x TASK - exclude a task (e.g. -x test)
  • --stacktrace / --info - more diagnostic output on failure
  • -P key=value - set a project property
  • --parallel - run independent tasks in parallel

Example in CI

Run a cached build and tests via the wrapper without a daemon:

shell
./gradlew build --build-cache --no-daemon --stacktrace

Common errors in CI

  • Could not resolve all files for configuration - repository or network/auth issue
  • Could not find com.example:lib:1.0 - dependency not in any configured repo
  • Execution failed for task ':test' - a test failed; see the report
  • Unsupported class file major version - JDK newer than Gradle supports

Key takeaways

  • Use ./gradlew and --no-daemon in CI for reproducible, ephemeral builds.
  • Enable --build-cache and cache ~/.gradle to speed up runs.
  • Most CI failures are dependency resolution or a JDK/Gradle version mismatch.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →