From 7dc90b929df4f888655abc6d047c55dd62365b07 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 21 Dec 2024 13:13:26 +0300 Subject: [PATCH] publish all targets by default --- gradle/libs.versions.toml | 2 +- .../kscience/gradle/KScienceExtension.kt | 43 ++++++++++--------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 28156b1..7145994 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,7 +6,7 @@ tools = "0.16.0-kotlin-2.1.0" atomicfu = "0.26.1" changelog = "2.2.1" compose = "1.7.1" -dokka = "2.0.0-Beta" +dokka = "2.0.0" jsBom = "1.0.0-pre.847" junit = "5.10.2" kotlin-jupyter = "0.12.0-352" diff --git a/src/main/kotlin/space/kscience/gradle/KScienceExtension.kt b/src/main/kotlin/space/kscience/gradle/KScienceExtension.kt index 5e850db..b6ea52e 100644 --- a/src/main/kotlin/space/kscience/gradle/KScienceExtension.kt +++ b/src/main/kotlin/space/kscience/gradle/KScienceExtension.kt @@ -287,41 +287,42 @@ public class KScienceNativeConfiguration(private val project: Project) { internal companion object { - private fun defaultNativeTargets(project: Project): Map = - when (val targets = project.requestPropertyOrNull("publishing.targets")) { - null -> { - listOf( - KScienceNativeTarget.linuxX64, - KScienceNativeTarget.mingwX64, - KScienceNativeTarget.macosX64, - KScienceNativeTarget.macosArm64, - KScienceNativeTarget.iosX64, - KScienceNativeTarget.iosArm64, - KScienceNativeTarget.iosSimulatorArm64, - ) - } - else -> { - targets.split(",").map { KScienceNativeTarget(KotlinNativePreset.valueOf(it)) } - } - }.associateBy { it.preset } + private fun defaultNativeTargets(project: Project): Set = + if (project.isInDevelopment) { + setOf(KScienceNativeTarget.linuxX64) + } else when (val targets = project.requestPropertyOrNull("publishing.targets")) { + null -> setOf( + KScienceNativeTarget.linuxX64, + KScienceNativeTarget.mingwX64, + KScienceNativeTarget.macosX64, + KScienceNativeTarget.macosArm64, + KScienceNativeTarget.iosX64, + KScienceNativeTarget.iosArm64, + KScienceNativeTarget.iosSimulatorArm64, + ) + + else -> targets.split(",").mapTo(HashSet()) { + KScienceNativeTarget(KotlinNativePreset.valueOf(it)) + } + } } - internal var targets: Map = defaultNativeTargets(project) + internal var targets: Set = defaultNativeTargets(project) /** * Replace all targets */ public fun setTargets(vararg target: KScienceNativeTarget) { - targets = target.associateBy { it.preset } + targets = target.toSet() } /** * Add a native target */ public fun target(target: KScienceNativeTarget) { - targets += target.preset to target + targets += target } public fun target( @@ -469,7 +470,7 @@ public abstract class KScienceMppExtension @Inject constructor(project: Project) val nativeConfiguration = KScienceNativeConfiguration(this).apply(block) pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { configure { - nativeConfiguration.targets.values.forEach { nativeTarget -> + nativeConfiguration.targets.forEach { nativeTarget -> when (nativeTarget.preset) { KotlinNativePreset.linuxX64 -> linuxX64( nativeTarget.targetName,