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

View File

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