Skip to content

Keep Kotlin compile configs of composite builds apart - #1065

Merged
christoph-sg merged 1 commit into
mainfrom
fix-kotlin-config-collisions
Nov 4, 2026
Merged

christoph-sg merged 1 commit into
mainfrom
fix-kotlin-config-collisions

Conversation

@christoph-sg

@christoph-sg christoph-sg commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

After the Kotlin compile tasks, the Gradle plugin writes each task's sources and classpath to <targetroot>/kotlin-configs/ for the CLI to index. The file was named after the sanitized task path, which collided in two ways:

  • Task paths are only unique within one build. In a composite build, the root build and an included build both have :compileKotlin, both wrote -compileKotlin.txt, and the later one replaced the earlier, so the included build's sources were missing from the index.
  • Sanitizing is lossy: :a-b:compileKotlin and :a:b:compileKotlin both became -a-b-compileKotlin.txt.

The file is now named <task name>-<hash>.txt, where the hash covers the build's root directory and the task path. The CLI reads every *.txt in the directory, so it needs no change.

Test

The new kotlin-composite fixture has Kotlin sources in the root build, an included build, and subprojects :a-b and :a:b, and expects all four in the index. Before the fix, running the CLI on it produced two configs and indexed only Root.kt and Nested.kt. All 24 tests in GradleBuildToolTest pass.

@christoph-sg
christoph-sg force-pushed the fix-kotlin-config-collisions branch from 2300070 to 494855c Compare November 4, 2026 14:09
@christoph-sg
christoph-sg changed the base branch from main to ch/fix-kotlin-gradle-cache November 4, 2026 14:09
Base automatically changed from ch/fix-kotlin-gradle-cache to main November 4, 2026 14:17
The Gradle plugin named each Kotlin config file after the sanitized task
path. Task paths are only unique within one build, so the root build and
an included build both wrote -compileKotlin.txt and the later one
replaced the earlier, dropping its sources from the index. Sanitizing
also mapped :a-b:compileKotlin and 🅰️b:compileKotlin to the same name.

Name the file after a hash of the build's root directory and the task
path instead.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1a6a2-f2b0-775c-a192-e5d11290c493
Co-authored-by: Christoph Hegemann <christoph.hegemann@sourcegraph.com>
@christoph-sg
christoph-sg force-pushed the fix-kotlin-config-collisions branch from 494855c to 8483da7 Compare November 4, 2026 14:18
@christoph-sg
christoph-sg enabled auto-merge (squash) November 4, 2026 14:29
@christoph-sg
christoph-sg merged commit e66c04f into main Nov 4, 2026
29 checks passed
@christoph-sg
christoph-sg deleted the fix-kotlin-config-collisions branch November 4, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants