gradle build: The Full Build Lifecycle Task
gradle build is an aggregate lifecycle task that depends on assemble and check, so it both produces artifacts and runs verification.
build is the task most CI jobs invoke. Knowing it is just assemble plus check explains why it compiles, packages, and runs tests in one shot.
What it does
The build task is a lifecycle task added by the base plugin. It has no actions of its own; it depends on assemble (produce the outputs, e.g. the jar) and check (run all verification, including test). So ./gradlew build compiles, packages, and tests in dependency order.
Common usage
./gradlew build
./gradlew build -x test # build but skip tests
./gradlew clean build # fresh build
./gradlew build --scan # build with a build scan linkFlags
| Flag | What it does |
|---|---|
| -x <task> | Exclude a task, e.g. -x test to skip tests |
| --scan | Publish a build scan for diagnostics |
| --console=plain | Disable the rich console (cleaner CI logs) |
| -S / --full-stacktrace | Print full stacktraces on failure |
| --warning-mode all | Surface deprecation warnings |
In CI
Run ./gradlew --no-daemon build on ephemeral runners so no daemon lingers, and cache ~/.gradle/caches and ~/.gradle/wrapper between jobs. Add --build-cache to reuse task outputs. --console=plain keeps the log readable in CI.
Common errors in CI
"Execution failed for task ':test'" with "There were failing tests" means check failed, not the packaging; the report is under build/reports/tests. "Task 'build' not found in root project" in a multi-project build means you must qualify it, e.g. :app:build. "Could not resolve all files for configuration ':compileClasspath'" is a dependency/network problem, not a build logic error.