Skip to content

Commit

Permalink
fix(gradle-plugin): Build with the lowest supported Java version
Browse files Browse the repository at this point in the history
Align with `gradle-model` to avoid problems when starting to build all
of ORT with a newer Java version.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Oct 3, 2024
1 parent c9d114c commit f272825
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions plugins/package-managers/gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
* License-Filename: LICENSE
*/

import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
// Apply core plugins.
`java-gradle-plugin`
Expand All @@ -39,6 +42,21 @@ dependencies {
api(libs.maven.model.builder)
}

// Classes that are sent to the build via custom build actions need to target the lowest supported Java version, which
// is Java 8 for Gradle 5 and above, see
// https://docs.gradle.org/current/userguide/third_party_integration.html#sec:embedding_compatibility
val gradleToolingApiLowestSupportedJavaVersion = JvmTarget.JVM_1_8

tasks.named<JavaCompile>("compileJava") {
targetCompatibility = gradleToolingApiLowestSupportedJavaVersion.target
}

tasks.named<KotlinCompile>("compileKotlin") {
compilerOptions {
jvmTarget = gradleToolingApiLowestSupportedJavaVersion
}
}

tasks.register<Jar>("fatJar") {
description = "Creates a fat JAR that includes all required runtime dependencies."
group = "Build"
Expand Down

0 comments on commit f272825

Please sign in to comment.