Parallel Bits - Which Parts of Gradle Run in Parallel
By default, nearly the entire invocation of Gradle is done serially, but there are ways to make it partially parallel.
The list is ordered from the mostly safe to less stable options.
Parallel task execution for tasks in separate projects
Historically, enabled when using Gradle Parallel Execution
mode with org.gradle.parallel=true, but now it is also achieved by enabling Gradle configuration caching feature
with org.gradle.configuration-cache=true. Configuration cache enables stricter rules in the build and therefore is
safer to use than the parallel execution mode.
Parallel task execution for tasks within the same project
Enabling Gradle configuration caching feature
with org.gradle.configuration-cache=true. Note, despite org.gradle.parallel=true sounding like it would do this,
it does not in fact enable this except for a narrow set of tasks that use Gradle worker API
Parallel execution for workers within a single task
Implement tasks using Gradle worker API and enable either
Gradle configuration caching feature
with org.gradle.configuration-cache=true or Gradle Parallel Execution
mode with org.gradle.parallel=true.
Parallel IDE model building during Gradle Sync
Enabling Gradle Parallel Execution
mode with org.gradle.parallel=true and using Android Studio Electric Eel
or newer.
Parallel test execution within a JVM test task
Setting the number of parallel forks via Test.setMaxParallelForks.
Parallel Android Gradle Plugin R8 task execution
Setting android.r8.maxWorkers
Parallel Configuration Cache loading
Enabling Gradle configuration caching feature
with org.gradle.configuration-cache=true does this automatically as long as you use Gradle 8.11
or newer.
Parallel Configuration Cache storing
Enabling Gradle configuration cache parallel store feature
with org.gradle.configuration-cache.parallel=true when using Gradle 8.11
or newer. Partially unsafe as it requires build logic and all plugins to avoid reaching cross-projects while configuring
projects.
build.gradle(.kts) compilation
Enable Gradle Isolated Projects feature with
org.gradle.unsafe.isolated-projects=true. Quite unsafe as Isolated Projects is still incubating.
Parallel configuration of projects
Enable Gradle Isolated Projects feature with
org.gradle.unsafe.isolated-projects=true. Quite unsafe as Isolated Projects is still incubating.
I hope this helps you get a sense of the toggles you have to control the Gradle build parallelism.