Teodora Mihaila
08/21/2025, 12:14 PMrewrite-kotlin
module I get the following error:
Caused by: java.lang.NoSuchMethodError: 'org.jetbrains.kotlin.buildtools.api.jvm.ClasspathEntrySnapshot org.jetbrains.kotlin.buildtools.api.CompilationService.calculateClasspathSnapshot(java.io.File, org.jetbrains.kotlin.buildtools.api.jvm.ClassSnapshotGranularity, boolean)'
along with the following warning:
w: ⚠️ 'org.jetbrains.kotlin:kotlin-compiler-embeddable' Artifact Present in Build Classpath
The artifact `org.jetbrains.kotlin:kotlin-compiler-embeddable` is present in the build classpath along Kotlin Gradle plugin.
This may lead to unpredictable and inconsistent behavior.
I think it's important mentioning that I get when same error even when just trying to upgrade from Kotlin 1.9.25 to 2.2.0 in the main repo without the changes from the PR.
From what I understand the cause of the error is a transitive dependency from the Kotlin Gradle plugin that introduces an older version on the build class path.
So far I have tried to fix this by doing the following:
1. Exploring the config files for any hardcoded old Kotlin version, but nothing was found.
2. Commenting out the dependencies in the build.gradle.kts
file of rewrite-kotlin module
to prevent transitive leaks. Nothing changed.
3. Using the following command: ./gradlew :rewrite-kotlin:dependencies | grep -A 5 "kotlin-compiler-embeddable"
to check which version of kotlin-compiler-embeddable
was Gradle resolving. The versions all appeared to match the set Kotlin language version.
4. Disabled classpath snapshots into gradle.properties
by adding: kotlin.incremental.useClasspathSnapshot=false
. Nothing changed.
5. Testing multiple Gradle/JDK combinations: Gradle versions between 8.14.3 & 9.0.0 with JDK 17, 21, 23, 24. Nothing changed.
Does anyone have any pointers on what could be going wrong and how to fix it?tapchicoma
08/21/2025, 12:26 PMmbonnin
08/21/2025, 12:42 PM./gradlew :buildEnvironment
------------------------------------------------------------
Root project 'rewrite' - Eliminate tech-debt. Automatically.
------------------------------------------------------------
classpath
+--- org.openrewrite.build.root:org.openrewrite.build.root.gradle.plugin:latest.release -> 2.3.0
| \--- org.openrewrite:rewrite-build-gradle-plugin:2.3.0
| +--- org.openrewrite:rewrite-gradle:8.56.1
| | +--- org.openrewrite:rewrite-kotlin:8.56.1
| | | +--- org.jetbrains:annotations:26.0.2 -> 13.0
| | | +--- org.openrewrite:rewrite-java:8.56.1 (*)
| | | +--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.25 -> 2.2.10
The rewrite-gradle-plugin pulls its own kotlin-compiler-embeddable
, which might or might not be compatible with the one from KGPmbonnin
08/21/2025, 12:43 PMrewrite-gradle-plugin
in isolated classloadersTeodora Mihaila
08/21/2025, 1:32 PMVampire
08/21/2025, 1:34 PMbecause I don't have a Develocity accountIsn't this about FOSS? Just create one on scans.gradle.org?
Teodora Mihaila
08/21/2025, 2:05 PMVampire
08/21/2025, 2:14 PMorg.openrewrite.build.root
plugin 2.3.0 which depends on rewrite-kotlin
8.56.1 which depends on kotlin-compiler-embeddable
1.9.25 I'd say and with that the newer KGP is not happy.Vampire
08/21/2025, 2:15 PM