Sergey Aldoukhov
04/17/2023, 5:12 PMkotlin {
...
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
...
}
...
sourceSets {
val nativeMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-cli:0.3.5")
}
}
val nativeMac by creating {
dependsOn(nativeMain)
dependencies {
implementation("io.ktor:ktor-client-darwin:$ktorVersion")
}
}
}
}
And I’m getting
The Kotlin source set nativeMac was configured but not added to any Kotlin compilation. You can add a source set to a target's compilation by connecting it with the compilation's default source set using 'dependsOn'.
See <https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets>
But I can’t figure how to “add a source set to a target’s compilation”, also the link in the warning goes to nowhere.vbsteven
04/17/2023, 5:16 PMephemient
04/17/2023, 5:21 PMnativeMac
to something. also just go ahead and add all targets regardless of the host, the ones which can't be built will be automatically skipped
kotlin {
macosX64()
linuxX64()
sourceSets {
val nativeMac by creating { ... }
val macosX64Main by getting {
dependsOn(nativeMac)
ephemient
04/17/2023, 5:23 PMmacosX64Main
→ macosMain
→ appleMain
→ nativeMain
→ commonMain
Sergey Aldoukhov
04/17/2023, 5:56 PMnativeTarget.apply {
binaries {
executable {
entryPoint = "main"
}
}
}
Sergey Aldoukhov
04/17/2023, 5:57 PMval nativeMain by getting {
when (nativeTarget.konanTarget) {
KonanTarget.LINUX_ARM64 -> dependsOn(nativeLinux)
KonanTarget.LINUX_X64 -> dependsOn(nativeLinux)
KonanTarget.MACOS_ARM64 -> dependsOn(nativeMac)
KonanTarget.MACOS_X64 -> dependsOn(nativeMac)
KonanTarget.MINGW_X64 -> dependsOn(nativeWindows)
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-cli:0.3.5")
}
}
Sergey Aldoukhov
04/17/2023, 6:01 PMephemient
04/17/2023, 6:03 PMnative
. that'll collide with the new automatic hierarchy and is unnecessary when you can just register all targets without issueSergey Aldoukhov
04/17/2023, 6:09 PMephemient
04/17/2023, 6:11 PMkotlin {
linuxArm64()
linuxX64()
macosArm64()
macosX64()
mingwX64()
or whatever the full set of your desired targets isSergey Aldoukhov
04/17/2023, 6:11 PMephemient
04/17/2023, 6:11 PM