Skip to content

Commit

Permalink
Allow running integration tests with JDK 21
Browse files Browse the repository at this point in the history
The Kotlin compiler cannot yet produce Java 21 bytecode,
but we possibly need to set a toolchain to the Kotlin
compiler for when the target test JDK is different from
the current JDK (used as default toolchain).
Instead of always using the target test JDK as compilation
toolchain (which would break when testing with JDK 21),
then use the lowest of the two: this ensures the bytecode
will be compatible with the target test JDK, without
requiring a too recent, and Kotlin-unsupported, compilation
toolchain.
  • Loading branch information
tbroyer committed Oct 8, 2023
1 parent 2aaeecc commit 7c6e7b6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions integTest/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ plugins {
`embedded-kotlin`
}

// Use the lowest toolchain to compile the code, such that produced bytecode
// is compatible with the target test toolchain.
project.findProperty("test.java-toolchain")?.also { testJavaToolchain ->
java {
toolchain {
languageVersion = JavaLanguageVersion.of(testJavaToolchain.toString())
val testVersion = JavaLanguageVersion.of(testJavaToolchain.toString())
if (testVersion < JavaLanguageVersion.of(JavaVersion.current().toString())) {
java {
toolchain {
languageVersion = testVersion
}
}
}
}
Expand Down

0 comments on commit 7c6e7b6

Please sign in to comment.