publish all targets by default

This commit is contained in:
Alexander Nozik 2024-12-21 13:13:26 +03:00
parent d12497ebe2
commit 7dc90b929d
2 changed files with 23 additions and 22 deletions

View File

@ -6,7 +6,7 @@ tools = "0.16.0-kotlin-2.1.0"
atomicfu = "0.26.1" atomicfu = "0.26.1"
changelog = "2.2.1" changelog = "2.2.1"
compose = "1.7.1" compose = "1.7.1"
dokka = "2.0.0-Beta" dokka = "2.0.0"
jsBom = "1.0.0-pre.847" jsBom = "1.0.0-pre.847"
junit = "5.10.2" junit = "5.10.2"
kotlin-jupyter = "0.12.0-352" kotlin-jupyter = "0.12.0-352"

View File

@ -287,10 +287,11 @@ public class KScienceNativeConfiguration(private val project: Project) {
internal companion object { internal companion object {
private fun defaultNativeTargets(project: Project): Map<KotlinNativePreset, KScienceNativeTarget> = private fun defaultNativeTargets(project: Project): Set<KScienceNativeTarget> =
when (val targets = project.requestPropertyOrNull("publishing.targets")) { if (project.isInDevelopment) {
null -> { setOf(KScienceNativeTarget.linuxX64)
listOf( } else when (val targets = project.requestPropertyOrNull("publishing.targets")) {
null -> setOf(
KScienceNativeTarget.linuxX64, KScienceNativeTarget.linuxX64,
KScienceNativeTarget.mingwX64, KScienceNativeTarget.mingwX64,
KScienceNativeTarget.macosX64, KScienceNativeTarget.macosX64,
@ -299,29 +300,29 @@ public class KScienceNativeConfiguration(private val project: Project) {
KScienceNativeTarget.iosArm64, KScienceNativeTarget.iosArm64,
KScienceNativeTarget.iosSimulatorArm64, KScienceNativeTarget.iosSimulatorArm64,
) )
else -> targets.split(",").mapTo(HashSet()) {
KScienceNativeTarget(KotlinNativePreset.valueOf(it))
} }
else -> {
targets.split(",").map { KScienceNativeTarget(KotlinNativePreset.valueOf(it)) }
} }
}.associateBy { it.preset }
} }
internal var targets: Map<KotlinNativePreset, KScienceNativeTarget> = defaultNativeTargets(project) internal var targets: Set<KScienceNativeTarget> = defaultNativeTargets(project)
/** /**
* Replace all targets * Replace all targets
*/ */
public fun setTargets(vararg target: KScienceNativeTarget) { public fun setTargets(vararg target: KScienceNativeTarget) {
targets = target.associateBy { it.preset } targets = target.toSet()
} }
/** /**
* Add a native target * Add a native target
*/ */
public fun target(target: KScienceNativeTarget) { public fun target(target: KScienceNativeTarget) {
targets += target.preset to target targets += target
} }
public fun target( public fun target(
@ -469,7 +470,7 @@ public abstract class KScienceMppExtension @Inject constructor(project: Project)
val nativeConfiguration = KScienceNativeConfiguration(this).apply(block) val nativeConfiguration = KScienceNativeConfiguration(this).apply(block)
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
configure<KotlinMultiplatformExtension> { configure<KotlinMultiplatformExtension> {
nativeConfiguration.targets.values.forEach { nativeTarget -> nativeConfiguration.targets.forEach { nativeTarget ->
when (nativeTarget.preset) { when (nativeTarget.preset) {
KotlinNativePreset.linuxX64 -> linuxX64( KotlinNativePreset.linuxX64 -> linuxX64(
nativeTarget.targetName, nativeTarget.targetName,