Using new Kotlin multiplatform hierarchy structure

This commit is contained in:
dankito 2023-07-06 15:43:23 +02:00
parent d702c605b2
commit 1f9d35a5f6
2 changed files with 56 additions and 54 deletions

View File

@ -6,40 +6,42 @@ plugins {
kotlin { kotlin {
// Enable the default target hierarchy:
targetHierarchy.default()
jvm { jvm {
compilations.all { jvmToolchain(8)
kotlinOptions.jvmTarget = '1.8' withJava() // not allowed if android { } is present
}
withJava()
testRuns["test"].executionTask.configure { testRuns["test"].executionTask.configure {
useJUnitPlatform() useJUnitPlatform()
testLogging { // This is for logging and can be removed.
events("passed", "skipped", "failed")
}
} }
} }
js(IR) { js(IR) {
binaries.executable() // binaries.executable()
browser { browser {
testTask { testTask {
useKarma { useKarma {
// we cannot assume that Chrome and Firefox are installed on all systems useChromeHeadless()
// useChromeHeadless() useFirefoxHeadless()
// useFirefox()
enabled = false
}
}
}
nodejs {
testTask {
useMocha {
enabled = true
}
testLogging {
events "failed"
} }
} }
} }
nodejs()
} }
linuxX64()
mingwX64()
ios { ios {
binaries { binaries {
framework { framework {
@ -47,14 +49,13 @@ kotlin {
} }
} }
} }
iosSimulatorArm64()
def hostOs = System.getProperty("os.name") macosX64()
def isMingwX64 = hostOs.startsWith("Windows") macosArm64()
def nativeTarget watchos()
if (hostOs == "Mac OS X") nativeTarget = macosX64('native') { binaries.executable() } watchosSimulatorArm64()
else if (hostOs == "Linux") nativeTarget = linuxX64("native") { binaries.executable() } tvos()
else if (isMingwX64) nativeTarget = mingwX64("native") { binaries.executable() } tvosSimulatorArm64()
else throw new GradleException("Host OS is not supported in Kotlin/Native.")
sourceSets { sourceSets {

View File

@ -8,40 +8,42 @@ group = "net.codinux.utils"
kotlin { kotlin {
// Enable the default target hierarchy:
targetHierarchy.default()
jvm { jvm {
compilations.all { jvmToolchain(8)
kotlinOptions.jvmTarget = '1.8' withJava() // not allowed if android { } is present
}
withJava()
testRuns["test"].executionTask.configure { testRuns["test"].executionTask.configure {
useJUnitPlatform() useJUnitPlatform()
testLogging { // This is for logging and can be removed.
events("passed", "skipped", "failed")
}
} }
} }
js(IR) { js(IR) {
binaries.executable() // binaries.executable()
browser { browser {
testTask { testTask {
useKarma { useKarma {
// we cannot assume that Chrome and Firefox are installed on all systems useChromeHeadless()
// useChromeHeadless() useFirefoxHeadless()
// useFirefox()
enabled = false
}
}
}
nodejs {
testTask {
useMocha {
enabled = true
}
testLogging {
events "failed"
} }
} }
} }
nodejs()
} }
linuxX64()
mingwX64()
ios { ios {
binaries { binaries {
framework { framework {
@ -49,14 +51,13 @@ kotlin {
} }
} }
} }
iosSimulatorArm64()
def hostOs = System.getProperty("os.name") macosX64()
def isMingwX64 = hostOs.startsWith("Windows") macosArm64()
def nativeTarget watchos()
if (hostOs == "Mac OS X") nativeTarget = macosX64('native') watchosSimulatorArm64()
else if (hostOs == "Linux") nativeTarget = linuxX64("native") tvos()
else if (isMingwX64) nativeTarget = mingwX64("native") tvosSimulatorArm64()
else throw new GradleException("Host OS is not supported in Kotlin/Native.")
sourceSets { sourceSets {