Today I tried to upgrade to Kotlin 2.1.0 in my Gra...
# kotlin-dsl
h
Today I tried to upgrade to Kotlin 2.1.0 in my Gradle project • Java 21 • Gradle 8.11.1 with
--debug
prarameter when building the project, and got the following build error>
Copy code
11-28T11:39:13.093+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
2024-11-28T11:39:13.093+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
2024-11-28T11:39:13.094+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
2024-11-28T11:39:13.094+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
2024-11-28T11:39:13.094+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':compileKotlin'.
2024-11-28T11:39:13.094+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > 'void org.jetbrains.kotlin.cli.common.arguments.CommonToolArguments.setExtraWarnings(boolean)'
e
are you trying to change the version of Kotlin used in a Gradle plugin or kotlin-dsl build?
that is not supported, only `embeddedKotlin`/`embeddedKotlinVersion` are
h
Just updated the
jvm
,
spring
,
ksp
plugins to align with Kotlin
2.1.0
, and no changes to the Kotlin dsl config:
Copy code
kotlin {
    compilerOptions {
        apiVersion.set(KotlinVersion.KOTLIN_2_0)
        languageVersion.set(KotlinVersion.KOTLIN_2_0)
        jvmTarget.set(JvmTarget.fromTarget(javaVersion.toString()))
        freeCompilerArgs.addAll(
            "-Xjsr305=strict",
            "-opt-in=kotlin.RequiresOptIn",
            "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
        )
    }
}
But from the compatibility page you provided, there is no options for Kotlin 2.1.
e
ah if it's not a Gradle plugin then it isn't a
kotlin-dsl
issue
it's possible that you need to wait for Spring support. https://github.com/spring-projects/spring-framework/issues/33629
h
Oh, but I am not sure what calling an old Kotlin compiler API that does not exist at
the build time
.
e
actually the stack trace makes it look like you are using
kotlin-dsl
somewhere
wait no I misread
I think you may have plugins pulling in incompatible versions into the buildscript classpath
hard to tell from that though
h
yes, that is what I am afraid
From the Koltin channels, I got the Kotlinter gradle uses an old Kotlin compiler API that will raise the similar exceptions. We also used it in our projects.
The
--scan
report, still can not find the root cause. https://kotlinlang.slack.com/archives/C7L3JB43G/p1732768515988379
specify explicitly
kotlin-compiler-emebeddable
version as
2.1.0
Generally
Kotlinter
should not bring
kotlin-compiler-embeddable
into build classpath
u
if someone else finds this thread like i did, this seems to be fixed in kotlinter 5.0.0+