[#78] Fix build on Apple Silicon

This commit is contained in:
Carter Jernigan 2021-11-10 11:38:20 -05:00
parent 99c237f196
commit 0ba504fac1
2 changed files with 18 additions and 1 deletions

View File

@ -3,11 +3,23 @@ import org.gradle.jvm.toolchain.JavaToolchainSpec
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
extensions.findByType<org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension>()?.apply {
jvmToolchain {
val javaVersion = JavaVersion.toVersion(project.property("ANDROID_JVM_TARGET").toString())
val javaVersion = JavaVersion.toVersion(project.property("JVM_TOOLCHAIN").toString())
val javaLanguageVersion = JavaLanguageVersion.of(javaVersion.majorVersion)
(this as JavaToolchainSpec).languageVersion.set(javaLanguageVersion)
}
targets.matching { it.platformType.name == "jvm" }.all {
(this as org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget).apply {
val javaTargetVersion = project.property("ANDROID_JVM_TARGET").toString()
compilations.all {
kotlinOptions {
jvmTarget = javaTargetVersion
}
}
}
}
targets.all {
compilations.all {
kotlinOptions {

View File

@ -72,5 +72,10 @@ KOTLINX_COROUTINES_VERSION=1.5.2
KOTLIN_VERSION=1.5.31
ZCASH_SDK_VERSION=1.3.0-beta18
# Toolchain is the Java version used to build the application, which is separate from the
# Java version used to run the application. Android requires a minimum of 11. Apple Silicon
# requires a newer toolchain. Kotlin won't support Java 17 until Kotlin 1.6
JVM_TOOLCHAIN=16
# This shouldn't be changed, as Android doesn't support targets beyond Java 8
ANDROID_JVM_TARGET=1.8