What is Gradle's Project Isolation feature, and how do you enable it?
answer
- Each project configures only itself
- org.gradle.unsafe.isolated-projects=true
- No cross-project model access at config time
- Parallel + incremental configuration
- Builds on configuration cache
basics
~10 sProject Isolation makes each project's configuration independent so projects can't reach into each other at configuration time. You enable it with the flag org.gradle.unsafe.isolated-projects=true in gradle.properties.
solid answer
~40 sProject Isolation is an incubating Gradle feature that enforces strict boundaries between projects during configuration. Normally, a project's build script can read another project's model directly (e.g. `project(':lib').version` or cross-project task wiring). Project Isolation forbids that direct access, requiring isolated, well-defined channels instead. Because each project's configuration becomes independent of the others, Gradle can configure and cache projects **in parallel and incrementally**, and it can avoid reconfiguring unaffected projects. You opt in with `org.gradle.unsafe.isolated-projects=true` in `gradle.properties` (or `-Dorg.gradle.unsafe.isolated-projects=true`). It builds directly on the configuration cache model and implicitly enables it. The `unsafe` namespace signals it's still incubating and the flag/behavior may change.
code
toml · 3 lines# gradle.properties
org.gradle.unsafe.isolated-projects=true
# (configuration cache is enabled implicitly)
go deeper
Know it's an opt-in flag that isolates projects from each other and is set in gradle.properties.
Explain that it forbids cross-project configuration access so projects configure independently, enabling parallel/incremental configuration; name the flag and that it builds on the configuration cache.
Discuss the incubating status, implicit configuration-cache dependency, and the kinds of violations teams must fix before it pays off.
Frame it as the enabler for scaling configuration in large monorepos and the migration cost/benefit of adopting it org-wide.
## The problem it solves In a multi-project Gradle build, every build script runs in a shared model. During the **configuration phase** a script can freely reach into another project: read another project's `version`, mutate another project's tasks, or call `project(':other').someExtension`. This cross-project coupling means Gradle generally cannot reason about projects independently — a change anywhere can invalidate everything, and configuration is hard to parallelize safely. ## What Project Isolation does **Project Isolation** is an incubating feature that enforces a boundary: each project may only configure **itself**. Reaching into a sibling's mutable state at configuration time becomes a violation that Gradle reports. The build is then composed of isolated project models that interact only through well-defined, declarative channels (dependencies, shared `Provider` values, `buildSrc`/convention plugins, etc.). Because projects are now independent, Gradle can: - **Configure projects in parallel**, each on its own thread. - **Cache each project's configuration separately and incrementally**, so editing one project only invalidates that project (and its dependents), not the whole build. - Skip reconfiguring projects whose inputs didn't change. ## Relationship to the configuration cache Project Isolation **builds on the configuration cache**. The configuration cache stores the result of the configuration phase keyed by its inputs; Project Isolation extends that model so the unit of caching/parallelism is the *project* rather than the whole build. Enabling Project Isolation implicitly enables the configuration cache, and the same serialization/state-capture rules apply. ## Enabling it ```properties # gradle.properties org.gradle.unsafe.isolated-projects=true ``` The `unsafe` segment marks it as incubating — the property name and semantics can change between Gradle versions, and not all plugins are compatible yet. ## What to expect after enabling Gradle will report violations where your scripts or plugins break isolation (e.g. accessing another project's tasks). You fix these by replacing direct access with isolated alternatives, after which you get the parallel + incremental configuration benefits.
- Why is the property in the 'unsafe' namespace?It marks the feature as incubating — the property name and behavior are not yet stable and may change between Gradle releases, and not all plugins are compatible yet.
- Does enabling Project Isolation require the configuration cache?Yes — Project Isolation builds on the configuration cache model and enables it implicitly; the same state-capture/serialization rules apply per project.
Like giving each project its own walled office instead of an open-plan room: people can't lean over and rearrange a neighbour's desk, so each office can be set up by its own worker simultaneously.
saying these in an interview costs you the question
- Claiming Project Isolation is just parallel task execution (that's a separate setting, org.gradle.parallel).
- Saying it's GA/stable — it is incubating, hence the 'unsafe' flag.