Skip to content

Commit

Permalink
Set compilation targets instead of JVM toolchains
Browse files Browse the repository at this point in the history
The JDK 8 toolchain is particularly problematic on macOS + aarch64,
since by default it uses an X64 JDK.
  • Loading branch information
squarejesse committed Oct 17, 2024
1 parent 67fb106 commit 56947c0
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.dokka.DokkaConfiguration.Visibility
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask
import org.jetbrains.dokka.gradle.DokkaTaskPartial
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

buildscript {
repositories {
Expand Down Expand Up @@ -100,15 +102,25 @@ allprojects {
enabled = project.findProperty("signingInMemoryKey") != null
}

val javaVersion = JavaVersion.VERSION_1_8

plugins.withId("org.jetbrains.kotlin.multiplatform") {
configure<KotlinMultiplatformExtension> {
jvmToolchain(8)
val kotlin = extensions.getByName("kotlin") as KotlinMultiplatformExtension
kotlin.targets.withType(KotlinJvmTarget::class.java) {
compilerOptions {
freeCompilerArgs.add("-Xjdk-release=$javaVersion")
}
}
}

plugins.withId("org.jetbrains.kotlin.jvm") {
configure<KotlinJvmProjectExtension> {
jvmToolchain(8)
tasks.withType(JavaCompile::class.java).configureEach {
sourceCompatibility = javaVersion.toString()
targetCompatibility = javaVersion.toString()
}

tasks.withType(KotlinJvmCompile::class.java).configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(javaVersion.toString()))
}
}

Expand Down

0 comments on commit 56947c0

Please sign in to comment.