google / google/ksp

Generated files not accesible after upgrade to kotlin 2.0.0

Open
#1,940 16 comments 2 reactions 1 assignee Claimed by @jaschdoc View on GitHub
bug P3
Dominant language
Kotlin
Stars
3.5k
Forks
415
Avg merge
1d 2h
Merged PRs (30d)
53

Description

Trying to migrate to Kotlin 2.0.0 and KSP 2.0.0-1.0.21, and was unsuccessful, as none of the generated files which are present in the build folder are visible to the source.

Reproducer:

Use 'examples/multiplatform' from this repository, change gradle.properties to use kotlin 2.0.0 and appropriate ksp:
```diff
diff --git a/examples/multiplatform/gradle.properties b/examples/multiplatform/gradle.properties
index 97b2b488..0049d2e1 100644
--- a/examples/multiplatform/gradle.properties
+++ b/examples/multiplatform/gradle.properties
@@ -1,3 +1,3 @@
org.gradle.jvmargs=-Xmx2048M
-kotlinVersion=1.9.21
-kspVersion=1.9.21-1.0.15
+kotlinVersion=2.0.0
+kspVersion=2.0.0-1.0.21
```
Observed:
```
./gradlew workload:compileKotlinJvm

> Task :workload:kspKotlinJvm
w: [ksp] [Bar.kt, Baz.kt]
w: [ksp] [Bar.kt, Baz.kt, Foo.kt]

> Task :workload:compileKotlinJvm FAILED
e: file:///home/ionspin/tmp/ksp/ksp/examples/multiplatform/workload/src/commonMain/kotlin/com/example/Bar.kt:4:15 Unresolved reference 'Foo'.
e: file:///home/ionspin/tmp/ksp/ksp/examples/multiplatform/workload/src/commonMain/kotlin/com/example/Baz.kt:4:15 Unresolved reference 'Foo'.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':workload:compileKotlinJvm'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 695ms
5 actionable tasks: 2 executed, 3 up-to-date
```

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.