11import org.jetbrains.dokka.gradle.DokkaMultiModuleTask
2+ import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
3+ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
4+ import org.jetbrains.kotlin.konan.target.Family
5+ import java.io.ByteArrayOutputStream
26
37plugins {
48 val kotlinVer = System .getenv(" KOTLIN_VERSION_ENV" )?.ifBlank { null } ? : libs.versions.kotlin.get()
59 val kotestVer = System .getenv(" KOTEST_VERSION_ENV" )?.ifBlank { null } ? : libs.versions.kotest.get()
610 val kspVer = System .getenv(" KSP_VERSION_ENV" )?.ifBlank { null } ? : " $kotlinVer -${libs.versions.ksp.get()} "
711
8- id(" at.asitplus.gradle.conventions" ) version " 20250714 "
12+ id(" at.asitplus.gradle.conventions" ) version " 20250728 "
913 id(" io.kotest" ) version kotestVer
1014 kotlin(" multiplatform" ) version kotlinVer apply false
1115 kotlin(" plugin.serialization" ) version kotlinVer apply false
@@ -29,27 +33,54 @@ tasks.getByName("dokkaHtmlMultiModule") {
2933}
3034
3135subprojects {
32- // JVM runner
33- tasks.withType<Test >().configureEach {
34- useJUnitPlatform()
35- systemProperty(" kotest.framework.config.fqn" ,
36- " KotestConfig" )
37- }
36+ this .afterEvaluate {
37+ // doesn't build with latest signum, but doesn't matter either
38+ tasks.findByName(" iosX64Test" )?.let { it.enabled = false }
39+ tasks.findByName(" linkDebugTestIosX64" )?.let { it.enabled = false }
3840
39- // JS runner(s)
40- tasks.withType< org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest > ()
41- .configureEach {
42- environment(" KOTEST_FRAMEWORK_CONFIG_FQN" ,
43- " KotestConfig" )
44- }
41+ /* help the linker (yes, this is absolutely bonkers!)*/
42+ if (org.gradle.internal.os.OperatingSystem .current() == org.gradle.internal.os.OperatingSystem .MAC_OS ) {
43+ val devDir = System .getenv(" DEVELOPER_DIR" )?.ifEmpty { null }.let {
44+ if (it == null ) {
45+ val output = ByteArrayOutputStream ()
46+ project.exec {
47+ commandLine(" xcode-select" , " -p" )
48+ standardOutput = output
49+ }
50+ output.toString().trim()
51+ } else it
52+ }
4553
46- // Native runner(s)
47- tasks.matching { it.name.endsWith(" Test" ) && it is Exec }
48- .configureEach {
49- (this as Exec ).environment(" KOTEST_FRAMEWORK_CONFIG_FQN" ,
50- " KotestConfig" )
51- }
54+ logger.lifecycle(" DEV DIR points to $devDir " )
55+
56+ val swiftLib = " $devDir /Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/"
57+
58+ extensions.getByType<KotlinMultiplatformExtension >().targets.withType<KotlinNativeTarget >()
59+ .configureEach {
60+ val sub = when (konanTarget.family) {
61+ Family .IOS ->
62+ if (konanTarget.name.contains(" SIMULATOR" , true )) " iphonesimulator" else " iphoneos"
5263
64+ Family .OSX -> " macosx"
65+ Family .TVOS ->
66+ if (konanTarget.name.contains(" SIMULATOR" , true )) " appletvsimulator" else " appletvos"
67+
68+ Family .WATCHOS ->
69+ if (konanTarget.name.contains(" SIMULATOR" , true )) " watchsimulator" else " watchos"
70+
71+ else -> throw StopExecutionException (" Konan target ${konanTarget.name} is not recognized" )
72+ }
73+
74+ logger.lifecycle(" KONAN target is ${konanTarget.name} which resolves to $sub " )
75+ binaries.all {
76+ linkerOpts(
77+ " -L${swiftLib}$sub " ,
78+ " -L/usr/lib/swift"
79+ )
80+ }
81+ }
82+ }
83+ }
5384}
5485
5586val artifactVersion: String by extra
0 commit comments