Skip to content

Commit 6c42bcf

Browse files
committed
Upgrade to Kotlin 1.6.20-M1
This commit upgrades the Kotlin dependencies to 1.6.20-M1 and configures the build to generate Java 17 bytecode for Kotlin classes. Closes gh-27814
1 parent 2019e17 commit 6c42bcf

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ plugins {
33
id 'io.spring.nohttp' version '0.0.10'
44
id "io.freefair.aspectj" version '6.4.0' apply false
55
id 'org.jetbrains.dokka' version '1.6.0' apply false
6-
id 'org.jetbrains.kotlin.jvm' version '1.6.10' apply false
7-
id "org.jetbrains.kotlin.plugin.serialization" version '1.6.10' apply false
6+
id 'org.jetbrains.kotlin.jvm' version '1.6.20-M1' apply false
7+
id "org.jetbrains.kotlin.plugin.serialization" version '1.6.20-M1' apply false
88
id 'org.asciidoctor.jvm.convert' version '3.3.2'
99
id 'org.asciidoctor.jvm.pdf' version '3.3.2'
1010
id "org.unbroken-dome.xjc" version '2.0.0' apply false
@@ -33,7 +33,7 @@ configure(allprojects) { project ->
3333
mavenBom "io.r2dbc:r2dbc-bom:Borca-RELEASE"
3434
mavenBom "io.rsocket:rsocket-bom:1.1.1"
3535
mavenBom "org.eclipse.jetty:jetty-bom:11.0.7"
36-
mavenBom "org.jetbrains.kotlin:kotlin-bom:1.6.10"
36+
mavenBom "org.jetbrains.kotlin:kotlin-bom:1.6.20-M1"
3737
mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.0"
3838
mavenBom "org.jetbrains.kotlinx:kotlinx-serialization-bom:1.3.2"
3939
mavenBom "org.junit:junit-bom:5.8.2"
@@ -277,13 +277,13 @@ configure([rootProject] + javaProjects) { project ->
277277
kotlinOptions {
278278
languageVersion = "1.6"
279279
apiVersion = "1.6"
280-
freeCompilerArgs = ["-Xjsr305=strict", "-Xsuppress-version-warnings", "-Xopt-in=kotlin.RequiresOptIn"]
280+
freeCompilerArgs = ["-Xjsr305=strict", "-Xsuppress-version-warnings", "-opt-in=kotlin.RequiresOptIn"]
281281
allWarningsAsErrors = true
282282
}
283283
}
284284
compileTestKotlin {
285285
kotlinOptions {
286-
freeCompilerArgs = ["-Xjsr305=strict"]
286+
freeCompilerArgs = ["-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn"]
287287
}
288288
}
289289
}

gradle/toolchains.gradle

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
* One can choose the toolchain to use for compiling the MAIN sources and/or compiling
66
* and running the TEST sources. These options apply to Java, Kotlin and Groovy sources
77
* when available.
8-
* {@code "./gradlew check -PmainToolchain=8 -PtestToolchain=11"} will use:
8+
* {@code "./gradlew check -PmainToolchain=17 -PtestToolchain=18"} will use:
99
* <ul>
10-
* <li>a JDK8 toolchain for compiling the main SourceSet
11-
* <li>a JDK11 toolchain for compiling and running the test SourceSet
10+
* <li>a JDK17 toolchain for compiling the main SourceSet
11+
* <li>a JDK18 toolchain for compiling and running the test SourceSet
1212
* </ul>
1313
*
1414
* By default, the build will fall back to using the current JDK and 17 language level for all sourceSets.
@@ -21,11 +21,11 @@
2121
*
2222
* We can also configure ENV variables and let Gradle know about them:
2323
* {@code
24-
* $ echo JDK11
25-
* /opt/openjdk/java11
26-
* $ echo JDK15
27-
* /opt/openjdk/java15
28-
* $ ./gradlew -Porg.gradle.java.installations.fromEnv=JDK11,JDK15 check
24+
* $ echo JDK17
25+
* /opt/openjdk/java17
26+
* $ echo JDK18
27+
* /opt/openjdk/java18
28+
* $ ./gradlew -Porg.gradle.java.installations.fromEnv=JDK17,JDK18 check
2929
* }
3030
*
3131
* @author Brian Clozel
@@ -121,12 +121,12 @@ pluginManager.withPlugin("kotlin") {
121121
// Fallback to JDK17
122122
compileKotlin {
123123
kotlinOptions {
124-
jvmTarget = '1.8'
124+
jvmTarget = '17'
125125
}
126126
}
127127
compileTestKotlin {
128128
kotlinOptions {
129-
jvmTarget = '1.8'
129+
jvmTarget = '17'
130130
}
131131
}
132132
}
@@ -137,10 +137,9 @@ pluginManager.withPlugin("kotlin") {
137137
languageVersion = testLanguageVersion
138138
}
139139
// See https://kotlinlang.org/docs/gradle.html#attributes-specific-for-jvm
140-
def javaVersion = testLanguageVersion.toString() == '8' ? '1.8' : testLanguageVersion.toString()
141140
compileTestKotlin {
142141
kotlinOptions {
143-
jvmTarget = javaVersion
142+
jvmTarget = testLanguageVersion.toString()
144143
jdkHome = compiler.get().metadata.installationPath.asFile.absolutePath
145144
}
146145
}

spring-core/src/test/kotlin/org/springframework/core/KotlinReactiveAdapterRegistryTests.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.core
1818

1919
import kotlinx.coroutines.Deferred
20+
import kotlinx.coroutines.DelicateCoroutinesApi
2021
import kotlinx.coroutines.GlobalScope
2122
import kotlinx.coroutines.async
2223
import kotlinx.coroutines.flow.Flow
@@ -32,6 +33,7 @@ import reactor.test.StepVerifier
3233
import java.time.Duration
3334
import kotlin.reflect.KClass
3435

36+
@OptIn(DelicateCoroutinesApi::class)
3537
class KotlinReactiveAdapterRegistryTests {
3638

3739
private val registry = ReactiveAdapterRegistry.getSharedInstance()

spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/CoroutinesIntegrationTests.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.web.reactive.result.method.annotation
1818

1919
import kotlinx.coroutines.Deferred
20+
import kotlinx.coroutines.DelicateCoroutinesApi
2021
import kotlinx.coroutines.GlobalScope
2122
import kotlinx.coroutines.async
2223
import kotlinx.coroutines.delay
@@ -115,6 +116,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
115116
@ComponentScan(resourcePattern = "**/CoroutinesIntegrationTests*")
116117
open class WebConfig
117118

119+
@OptIn(DelicateCoroutinesApi::class)
118120
@RestController
119121
class CoroutinesController {
120122

0 commit comments

Comments
 (0)