Skip to content

Commit

Permalink
build(gradle): Use Java 21 to build the workbench
Browse files Browse the repository at this point in the history
This is a preparation for upgrading to ORT 35.0.0 which was built with
Java 21.

Even though GitHub runner image Ubuntu 24.04 still has Java 17 as the
default [1], it also has Java 21 installed and Gradle's toolchain
mechanism will find it without setting it up via the action.

[1]: https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md#java

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Oct 11, 2024
1 parent a3c07b9 commit a4d90b9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Build the JAR
uses: gradle/gradle-build-action@v3
with:
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Run Detekt
uses: gradle/gradle-build-action@v3
with:
Expand Down
15 changes: 12 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

val javaLanguageVersion: String by project

plugins {
alias(libs.plugins.compose)
alias(libs.plugins.compose.compiler)
Expand Down Expand Up @@ -77,10 +79,15 @@ tasks.named<DependencyUpdatesTask>("dependencyUpdates") {
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
toolchain {
languageVersion = JavaLanguageVersion.of(javaLanguageVersion)
vendor = JvmVendorSpec.ADOPTIUM
}
}

val maxKotlinJvmTarget = runCatching { JvmTarget.fromTarget(javaLanguageVersion) }
.getOrDefault(enumValues<JvmTarget>().max())

tasks.withType<KotlinCompile> {
val customCompilerArgs = listOf(
"-opt-in=androidx.compose.ui.ExperimentalComposeUiApi"
Expand All @@ -90,7 +97,7 @@ tasks.withType<KotlinCompile> {
allWarningsAsErrors = true
apiVersion = KotlinVersion.KOTLIN_1_8
freeCompilerArgs.addAll(customCompilerArgs)
jvmTarget = JvmTarget.JVM_17
jvmTarget = maxKotlinJvmTarget
}
}

Expand All @@ -102,6 +109,8 @@ detekt {
}

tasks.withType<Detekt>().configureEach {
jvmTarget = maxKotlinJvmTarget.target

reports {
xml.required.set(false)
html.required.set(false)
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ org.gradle.configuration-cache = true
org.gradle.kotlin.dsl.allWarningsAsErrors = true
org.gradle.parallel = true

javaLanguageVersion = 21

kotlin.code.style = official

0 comments on commit a4d90b9

Please sign in to comment.