Skip to content
Latchkey

gradle assemble: Produce Artifacts Without Testing

gradle assemble produces every project artifact (jars, wars, distributions) but runs no tests or verification, so it is faster than build.

When a CI stage only needs the packaged output (to ship to a later test or publish stage) assemble is the right task: it skips check entirely.

What it does

The assemble lifecycle task depends on the tasks that create the project outputs (jar, war, bootJar, distribution zips) but not on check. So it compiles main sources and packages them without compiling or running tests.

Common usage

Terminal
./gradlew assemble
./gradlew :app:assemble          # one module only
./gradlew clean assemble --build-cache

Flags

FlagWhat it does
--build-cacheReuse cached compile/jar outputs
--console=plainPlain log output for CI
-x <task>Exclude a packaging task you do not need
--infoShow which artifact tasks ran

In CI

Split pipelines often run assemble in a build stage and pass the jar to a separate test/check stage, so the artifact is produced once. Combine with --build-cache and a cached ~/.gradle to make repeat assembles near-instant.

Common errors in CI

"Execution failed for task ':compileJava'" is a compilation error (the source, not the packaging). "Entry ... is a duplicate but no duplicates strategy has been set" in a jar/war task means two files map to the same path; set duplicatesStrategy. If assemble produces nothing, no plugin that creates artifacts is applied (e.g. you applied only the java-library base without sources).

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →