Skip to content

Commit

Permalink
Upgrade to Kotlin 2.1.0
Browse files Browse the repository at this point in the history
Spring Framework 7.0 will use a Kotlin 2 baseline, using the latest 2.x
release at the time of the release.

This commit upgrades Kotlin to 2.1.0, and Kotlin Serialization and
Coroutines accordingly.

Closes gh-33629
  • Loading branch information
sdeleuze committed Dec 5, 2024
1 parent 58020ff commit 75e5747
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
1 change: 0 additions & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ ext {
dependencies {
checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:${javaFormatVersion}"
implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
implementation "org.jetbrains.kotlin:kotlin-compiler-embeddable:${kotlinVersion}"
implementation "org.gradle:test-retry-gradle-plugin:1.5.6"
implementation "io.spring.javaformat:spring-javaformat-gradle-plugin:${javaFormatVersion}"
implementation "io.spring.nohttp:nohttp-gradle:0.0.11"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,15 +16,14 @@

package org.springframework.build;

import java.util.ArrayList;
import java.util.List;

import org.gradle.api.Project;
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions;
import org.jetbrains.kotlin.gradle.dsl.JvmTarget;
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion;
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile;

/**
* @author Brian Clozel
* @author Sebastien Deleuze
*/
public class KotlinConventions {

Expand All @@ -34,15 +33,14 @@ void apply(Project project) {
}

private void configure(KotlinCompile compile) {
KotlinJvmOptions kotlinOptions = compile.getKotlinOptions();
kotlinOptions.setApiVersion("1.7");
kotlinOptions.setLanguageVersion("1.7");
kotlinOptions.setJvmTarget("17");
kotlinOptions.setJavaParameters(true);
kotlinOptions.setAllWarningsAsErrors(true);
List<String> freeCompilerArgs = new ArrayList<>(compile.getKotlinOptions().getFreeCompilerArgs());
freeCompilerArgs.addAll(List.of("-Xsuppress-version-warnings", "-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn"));
compile.getKotlinOptions().setFreeCompilerArgs(freeCompilerArgs);
compile.compilerOptions(options -> {
options.getApiVersion().set(KotlinVersion.KOTLIN_2_1);
options.getLanguageVersion().set(KotlinVersion.KOTLIN_2_1);
options.getJvmTarget().set(JvmTarget.JVM_17);
options.getJavaParameters().set(true);
options.getAllWarningsAsErrors().set(true);
options.getFreeCompilerArgs().addAll("-Xsuppress-version-warnings", "-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn");
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
= Requirements
:page-section-summary-toc: 1

Spring Framework supports Kotlin 1.7+ and requires
Spring Framework supports Kotlin 2.1+ and requires
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`]
to be present on the classpath. They are provided by default if you bootstrap a Kotlin project on
Expand Down
4 changes: 2 additions & 2 deletions framework-platform/framework-platform.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ dependencies {
api(platform("org.assertj:assertj-bom:3.26.3"))
api(platform("org.eclipse.jetty:jetty-bom:12.0.15"))
api(platform("org.eclipse.jetty.ee10:jetty-ee10-bom:12.0.15"))
api(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.8.1"))
api(platform("org.jetbrains.kotlinx:kotlinx-serialization-bom:1.6.3"))
api(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.9.0"))
api(platform("org.jetbrains.kotlinx:kotlinx-serialization-bom:1.7.3"))
api(platform("org.junit:junit-bom:5.11.3"))
api(platform("org.mockito:mockito-bom:5.14.2"))

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.caching=true
org.gradle.jvmargs=-Xmx2048m
org.gradle.parallel=true

kotlinVersion=1.9.25
kotlinVersion=2.1.0

kotlin.jvm.target.validation.mode=ignore
kotlin.stdlib.default.dependency=false
1 change: 1 addition & 0 deletions spring-context/spring-context.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dependencies {
testImplementation("org.awaitility:awaitility")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
testImplementation("io.projectreactor:reactor-test")
testImplementation("io.reactivex.rxjava3:rxjava")
testImplementation('io.micrometer:context-propagation')
testImplementation("io.micrometer:micrometer-observation-test")
Expand Down

0 comments on commit 75e5747

Please sign in to comment.