Upgrade to Kotlin 2.2.0

Kotlin 2.2 is the new baseline for Spring Framework 7.0.

-Xannotation-default-target=param-property is specified to avoid
warnings when compiling tests or documentation snippets. It is
expected to become the default behavior in an upcoming version
of Kotlin, see https://youtrack.jetbrains.com/issue/KT-73255 for
more details.

Closes gh-34453
This commit is contained in:
Sébastien Deleuze 2025-06-23 17:48:04 +02:00
parent fee873d8d2
commit ba9bef6bbf
4 changed files with 7 additions and 5 deletions

View File

@ -34,8 +34,8 @@ public class KotlinConventions {
private void configure(KotlinCompile compile) { private void configure(KotlinCompile compile) {
compile.compilerOptions(options -> { compile.compilerOptions(options -> {
options.getApiVersion().set(KotlinVersion.KOTLIN_2_1); options.getApiVersion().set(KotlinVersion.KOTLIN_2_2);
options.getLanguageVersion().set(KotlinVersion.KOTLIN_2_1); options.getLanguageVersion().set(KotlinVersion.KOTLIN_2_2);
options.getJvmTarget().set(JvmTarget.JVM_17); options.getJvmTarget().set(JvmTarget.JVM_17);
options.getJavaParameters().set(true); options.getJavaParameters().set(true);
options.getAllWarningsAsErrors().set(true); options.getAllWarningsAsErrors().set(true);
@ -43,7 +43,8 @@ public class KotlinConventions {
"-Xsuppress-version-warnings", "-Xsuppress-version-warnings",
"-Xjsr305=strict", // For dependencies using JSR 305 "-Xjsr305=strict", // For dependencies using JSR 305
"-opt-in=kotlin.RequiresOptIn", "-opt-in=kotlin.RequiresOptIn",
"-Xjdk-release=17" // Needed due to https://youtrack.jetbrains.com/issue/KT-49746 "-Xjdk-release=17", // Needed due to https://youtrack.jetbrains.com/issue/KT-49746
"-Xannotation-default-target=param-property" // Upcoming default, see https://youtrack.jetbrains.com/issue/KT-73255
); );
}); });
} }

View File

@ -46,6 +46,7 @@ repositories {
// To avoid a redeclaration error with Kotlin compiler // To avoid a redeclaration error with Kotlin compiler
tasks.named('compileKotlin', KotlinCompilationTask.class) { tasks.named('compileKotlin', KotlinCompilationTask.class) {
javaSources.from = [] javaSources.from = []
compilerOptions.freeCompilerArgs = [ "-Xannotation-default-target=param-property" ] // Upcoming default, see https://youtrack.jetbrains.com/issue/KT-73255
} }
dependencies { dependencies {

View File

@ -2,7 +2,7 @@
= Requirements = Requirements
:page-section-summary-toc: 1 :page-section-summary-toc: 1
Spring Framework supports Kotlin 2.1+ and requires Spring Framework supports Kotlin 2.2+ and requires
https://search.maven.org/artifact/org.jetbrains.kotlin/kotlin-stdlib[`kotlin-stdlib`] https://search.maven.org/artifact/org.jetbrains.kotlin/kotlin-stdlib[`kotlin-stdlib`]
and https://search.maven.org/artifact/org.jetbrains.kotlin/kotlin-reflect[`kotlin-reflect`] and https://search.maven.org/artifact/org.jetbrains.kotlin/kotlin-reflect[`kotlin-reflect`]
to be present on the classpath. They are provided by default if you bootstrap a Kotlin project on to be present on the classpath. They are provided by default if you bootstrap a Kotlin project on

View File

@ -4,7 +4,7 @@ org.gradle.caching=true
org.gradle.jvmargs=-Xmx2048m org.gradle.jvmargs=-Xmx2048m
org.gradle.parallel=true org.gradle.parallel=true
kotlinVersion=2.2.0-RC2 kotlinVersion=2.2.0
kotlin.jvm.target.validation.mode=ignore kotlin.jvm.target.validation.mode=ignore
kotlin.stdlib.default.dependency=false kotlin.stdlib.default.dependency=false