google / google/ksp

Command-line Isolated Projects flags are not reflected in KSP source wiring

Open
#3,188 0 comments 0 reactions 1 assignee Claimed by @hfmehmed View on GitHub
Gradle P2
Dominant language
Kotlin
Stars
3.5k
Forks
415
Avg merge
1d 2h
Merged PRs (30d)
53

Description

KSP's `enableProjectIsolationCompatibleCodepath()` reads Gradle/system properties directly, so it misses Gradle's `--isolated-projects` command-line flag. It also reports isolation enabled when `org.gradle.isolated-projects=true` is overridden by `--no-isolated-projects`.

This is present in KSP 2.3.11 and current main. The compatible source-registration path is selected by this function in both `KspSubplugin` and `KspAATask`.

A small Groovy build demonstrates the detection error:

```groovy
import com.google.devtools.ksp.gradle.utils.KgpUtilsKt

plugins {
id 'org.jetbrains.kotlin.jvm' version '2.3.20' apply false
id 'com.google.devtools.ksp' version '2.3.11' apply false
}

def isolated = KgpUtilsKt.enableProjectIsolationCompatibleCodepath(project)
tasks.register('checkIsolation') {
inputs.property('isolated', isolated)
doLast { println('KSP isolation: ' + inputs.properties.isolated) }
}
```

With Gradle 9.7.1:

- `./gradlew checkIsolation --isolated-projects` prints Gradle's isolation banner, but `KSP isolation: false`.
- Put `org.gradle.isolated-projects=true` in `gradle.properties`; `./gradlew checkIsolation --no-isolated-projects` prints `KSP isolation: true`.
- Explicit `ksp.project.isolation.enabled=true` remains a useful opt-in/workaround and should continue to work with Gradle isolation disabled.

I have reproduced both failures in focused TestKit tests against current main. `BuildFeatures.isolatedProjects.active` supplies Gradle's effective feature state, including CLI precedence. It is available since Gradle 8.5, so a version-gated injected helper can use it while retaining the existing property fallback on older Gradle versions.

I am preparing that small fix with CLI/cache-reuse, explicit opt-in, older-Gradle, and actual generated-source compilation coverage. This investigation and the tests are substantially AI-assisted with Codex.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.