Browse Source

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
pull/28041/head
Brian Clozel 3 years ago
parent
commit
6c42bcfaec
  1. 10
      build.gradle
  2. 23
      gradle/toolchains.gradle
  3. 2
      spring-core/src/test/kotlin/org/springframework/core/KotlinReactiveAdapterRegistryTests.kt
  4. 2
      spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/CoroutinesIntegrationTests.kt

10
build.gradle

@ -3,8 +3,8 @@ plugins { @@ -3,8 +3,8 @@ plugins {
id 'io.spring.nohttp' version '0.0.10'
id "io.freefair.aspectj" version '6.4.0' apply false
id 'org.jetbrains.dokka' version '1.6.0' apply false
id 'org.jetbrains.kotlin.jvm' version '1.6.10' apply false
id "org.jetbrains.kotlin.plugin.serialization" version '1.6.10' apply false
id 'org.jetbrains.kotlin.jvm' version '1.6.20-M1' apply false
id "org.jetbrains.kotlin.plugin.serialization" version '1.6.20-M1' apply false
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id 'org.asciidoctor.jvm.pdf' version '3.3.2'
id "org.unbroken-dome.xjc" version '2.0.0' apply false
@ -33,7 +33,7 @@ configure(allprojects) { project -> @@ -33,7 +33,7 @@ configure(allprojects) { project ->
mavenBom "io.r2dbc:r2dbc-bom:Borca-RELEASE"
mavenBom "io.rsocket:rsocket-bom:1.1.1"
mavenBom "org.eclipse.jetty:jetty-bom:11.0.7"
mavenBom "org.jetbrains.kotlin:kotlin-bom:1.6.10"
mavenBom "org.jetbrains.kotlin:kotlin-bom:1.6.20-M1"
mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.0"
mavenBom "org.jetbrains.kotlinx:kotlinx-serialization-bom:1.3.2"
mavenBom "org.junit:junit-bom:5.8.2"
@ -277,13 +277,13 @@ configure([rootProject] + javaProjects) { project -> @@ -277,13 +277,13 @@ configure([rootProject] + javaProjects) { project ->
kotlinOptions {
languageVersion = "1.6"
apiVersion = "1.6"
freeCompilerArgs = ["-Xjsr305=strict", "-Xsuppress-version-warnings", "-Xopt-in=kotlin.RequiresOptIn"]
freeCompilerArgs = ["-Xjsr305=strict", "-Xsuppress-version-warnings", "-opt-in=kotlin.RequiresOptIn"]
allWarningsAsErrors = true
}
}
compileTestKotlin {
kotlinOptions {
freeCompilerArgs = ["-Xjsr305=strict"]
freeCompilerArgs = ["-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn"]
}
}
}

23
gradle/toolchains.gradle

@ -5,10 +5,10 @@ @@ -5,10 +5,10 @@
* One can choose the toolchain to use for compiling the MAIN sources and/or compiling
* and running the TEST sources. These options apply to Java, Kotlin and Groovy sources
* when available.
* {@code "./gradlew check -PmainToolchain=8 -PtestToolchain=11"} will use:
* {@code "./gradlew check -PmainToolchain=17 -PtestToolchain=18"} will use:
* <ul>
* <li>a JDK8 toolchain for compiling the main SourceSet
* <li>a JDK11 toolchain for compiling and running the test SourceSet
* <li>a JDK17 toolchain for compiling the main SourceSet
* <li>a JDK18 toolchain for compiling and running the test SourceSet
* </ul>
*
* By default, the build will fall back to using the current JDK and 17 language level for all sourceSets.
@ -21,11 +21,11 @@ @@ -21,11 +21,11 @@
*
* We can also configure ENV variables and let Gradle know about them:
* {@code
* $ echo JDK11
* /opt/openjdk/java11
* $ echo JDK15
* /opt/openjdk/java15
* $ ./gradlew -Porg.gradle.java.installations.fromEnv=JDK11,JDK15 check
* $ echo JDK17
* /opt/openjdk/java17
* $ echo JDK18
* /opt/openjdk/java18
* $ ./gradlew -Porg.gradle.java.installations.fromEnv=JDK17,JDK18 check
* }
*
* @author Brian Clozel
@ -121,12 +121,12 @@ pluginManager.withPlugin("kotlin") { @@ -121,12 +121,12 @@ pluginManager.withPlugin("kotlin") {
// Fallback to JDK17
compileKotlin {
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '17'
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '17'
}
}
}
@ -137,10 +137,9 @@ pluginManager.withPlugin("kotlin") { @@ -137,10 +137,9 @@ pluginManager.withPlugin("kotlin") {
languageVersion = testLanguageVersion
}
// See https://kotlinlang.org/docs/gradle.html#attributes-specific-for-jvm
def javaVersion = testLanguageVersion.toString() == '8' ? '1.8' : testLanguageVersion.toString()
compileTestKotlin {
kotlinOptions {
jvmTarget = javaVersion
jvmTarget = testLanguageVersion.toString()
jdkHome = compiler.get().metadata.installationPath.asFile.absolutePath
}
}

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

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
package org.springframework.core
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.flow.Flow
@ -32,6 +33,7 @@ import reactor.test.StepVerifier @@ -32,6 +33,7 @@ import reactor.test.StepVerifier
import java.time.Duration
import kotlin.reflect.KClass
@OptIn(DelicateCoroutinesApi::class)
class KotlinReactiveAdapterRegistryTests {
private val registry = ReactiveAdapterRegistry.getSharedInstance()

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

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
package org.springframework.web.reactive.result.method.annotation
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
@ -115,6 +116,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() { @@ -115,6 +116,7 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() {
@ComponentScan(resourcePattern = "**/CoroutinesIntegrationTests*")
open class WebConfig
@OptIn(DelicateCoroutinesApi::class)
@RestController
class CoroutinesController {

Loading…
Cancel
Save