Skip to content

Commit 2551440

Browse files
committed
Allow JDK >= 21 instead of requiring exactly JDK 21
Replace jvmToolchain(21) with explicit jvmTarget and --release 21 compiler options so any JDK >= 21 can build the project while still producing Java 21-compatible bytecode. Update CI workflows from JDK 22 to JDK 25.
1 parent 81c9a9c commit 2551440

20 files changed

Lines changed: 47 additions & 51 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ jobs:
1818
- name: Copy CI gradle.properties
1919
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
2020

21-
- name: Set up JDK 22
21+
- name: Set up JDK 25
2222
uses: actions/setup-java@v5
2323
with:
2424
distribution: 'zulu'
25-
java-version: 22
25+
java-version: 25
2626

2727
- name: Set up Node.js
2828
uses: actions/setup-node@v6

.github/workflows/documentation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ jobs:
2929
- name: Checkout code
3030
uses: actions/checkout@v6
3131

32-
- name: Set up JDK 22
32+
- name: Set up JDK 25
3333
uses: actions/setup-java@v5
3434
with:
35-
java-version: '22'
35+
java-version: '25'
3636
distribution: 'temurin'
3737

3838
- name: Cache Gradle packages

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ jobs:
1212
steps:
1313
- name: Check out code
1414
uses: actions/checkout@v6
15-
- name: Set up JDK 22
15+
- name: Set up JDK 25
1616
uses: actions/setup-java@v5
1717
with:
1818
distribution: 'zulu'
19-
java-version: 22
19+
java-version: 25
2020
- name: Validate signing configuration
2121
run: |
2222
if ! grep -Eq '^[[:space:]]*signAllPublications[[:space:]]*=[[:space:]]*true[[:space:]]*$' gradle.properties; then

.github/workflows/schema-validation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
- name: Checkout code
1818
uses: actions/checkout@v6
1919

20-
- name: Set up JDK 22
20+
- name: Set up JDK 25
2121
uses: actions/setup-java@v5
2222
with:
23-
java-version: '22'
23+
java-version: '25'
2424
distribution: 'temurin'
2525

2626
- name: Cache Gradle packages

build-logic/convention/build.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ dependencies {
1919
}
2020

2121
kotlin {
22-
jvmToolchain(21)
22+
compilerOptions {
23+
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
24+
}
25+
}
26+
27+
tasks.withType<JavaCompile>().configureEach {
28+
options.release.set(21)
2329
}
2430

2531
gradlePlugin {

build.gradle.kts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,38 @@ allprojects {
1717
group = "sk.ainet"
1818
}
1919

20-
// Enforce a consistent JVM toolchain across all Kotlin modules to avoid bytecode mismatches
20+
// Require JDK 21+ but allow any newer version (produces Java 21 bytecode via --release / jvmTarget)
2121
subprojects {
22-
// Kotlin Multiplatform projects
22+
require(JavaVersion.current() >= JavaVersion.VERSION_21) {
23+
"This project requires JDK 21+, but found ${JavaVersion.current()}"
24+
}
25+
26+
// Kotlin Multiplatform projects – set jvmTarget on every JVM-like target
2327
plugins.withId("org.jetbrains.kotlin.multiplatform") {
2428
extensions.findByType(org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension::class.java)?.apply {
25-
jvmToolchain(21)
29+
targets.withType(org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget::class.java) {
30+
compilerOptions {
31+
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
32+
}
33+
}
2634
}
2735
}
2836
// Kotlin/JVM projects
2937
plugins.withId("org.jetbrains.kotlin.jvm") {
3038
extensions.findByType(org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension::class.java)?.apply {
31-
jvmToolchain(21)
39+
compilerOptions {
40+
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
41+
}
42+
}
43+
}
44+
45+
// Java sources – produce Java 21 bytecode regardless of the JDK used to compile.
46+
// Skip Android projects: AGP manages source/target compatibility itself and rejects --release.
47+
afterEvaluate {
48+
if (!plugins.hasPlugin("com.android.library") && !plugins.hasPlugin("com.android.application")) {
49+
tasks.withType<JavaCompile>().configureEach {
50+
options.release.set(21)
51+
}
3252
}
3353
}
3454

kotlin-js-store/wasm/yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
ws@8.18.0:
6+
version "8.18.0"
7+
resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc"
8+
integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==

skainet-apps/skainet-bert/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ plugins {
1111
}
1212

1313
kotlin {
14-
jvmToolchain(21)
15-
1614
androidTarget {
1715
publishLibraryVariants("release")
1816
@OptIn(ExperimentalKotlinGradlePluginApi::class)

skainet-apps/skainet-grayscale-cli/build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ plugins {
44
application
55
}
66

7-
kotlin {
8-
jvmToolchain(21)
9-
}
10-
117
dependencies {
128
implementation(kotlin("stdlib"))
139
implementation(libs.kotlinx.cli)

skainet-apps/skainet-kgemma/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ plugins {
1111
}
1212

1313
kotlin {
14-
jvmToolchain(21)
15-
1614
androidTarget {
1715
publishLibraryVariants("release")
1816
@OptIn(ExperimentalKotlinGradlePluginApi::class)

0 commit comments

Comments
 (0)