Norbi
08/15/2024, 3:50 PM> Task :...:kspCommonMainKotlinMetadata FAILED
e: -api-version (2.0) cannot be greater than -language-version (1.9)
But I set both the language version and the API version to 2.0 in the parent Gradle project, at the same source code location in the build script.
Nevertheless, I tried to set the version directly in the subproject with several methods, none of them works.
For example like it is in the documentation:
tasks.named<KotlinCompilationTask<*>>("compileKotlin").configure {
compilerOptions {
apiVersion.set(KOTLIN_2_0)
languageVersion.set(KOTLIN_2_0)
}
}
// ERROR: Task with name 'compileKotlin' not found in project ...
Using a similar Gradle task based method:
tasks.withType<KotlinCompilationTask<*>>().configureEach {
compilerOptions {
apiVersion.set(KOTLIN_2_0)
languageVersion.set(KOTLIN_2_0)
}
}
// Doesn't work
And also in the config block:
kotlin {
compilerOptions {
apiVersion.set(KOTLIN_2_0)
languageVersion.set(KOTLIN_2_0)
}
}
// Doesn't work
Kotlin version: 2.0.20.RC2
Thanks.Norbi
08/16/2024, 1:41 PMmbonnin
08/16/2024, 5:51 PMuseKSP2 = true
Norbi
08/16/2024, 6:22 PMStephan Schröder
08/17/2024, 4:10 PMUnlike KSP 1.x, it is no longer a compiler plugin and is built on the same set of Kotlin compiler APIs shared with IntelliJ IDEA, Android Lint, etc. Compared to the compiler-plugin approach, this allows a finer control of the program life cycle, simplifies KSP’s implementation and is more efficient. It is also a response to the compiler migration to K2, whose compiler plugin API is different from the one KSP1 uses.from Introduction to KSP2 (Beta) You probably have to adapt all of your KSP-plugins.