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 --stacktraceCommon 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
./gradlewand--no-daemonin CI for reproducible, ephemeral builds. - Enable
--build-cacheand cache~/.gradleto speed up runs. - Most CI failures are dependency resolution or a JDK/Gradle version mismatch.
Related guides
mvn Command: Build Maven Projects in CImvn is the Maven build tool. Reference for clean, install, verify, -B, -DskipTests, -P, -pl, and the Maven CI…
javac Command: Compile Java in CIjavac is the Java compiler. Reference for -d, -cp/-classpath, --release, -source/-target, -Xlint, and the pac…
bazel Command: Build Monorepos in CIbazel is a hermetic, cached build system. Reference for build, test, //..., --config, --remote_cache, --keep_…