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"
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"

View File

@ -287,41 +287,42 @@ public class KScienceNativeConfiguration(private val project: Project) {
internal companion object {
private fun defaultNativeTargets(project: Project): Map<KotlinNativePreset, KScienceNativeTarget> =
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<KScienceNativeTarget> =
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<KotlinNativePreset, KScienceNativeTarget> = defaultNativeTargets(project)
internal var targets: Set<KScienceNativeTarget> = 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<KotlinMultiplatformExtension> {
nativeConfiguration.targets.values.forEach { nativeTarget ->
nativeConfiguration.targets.forEach { nativeTarget ->
when (nativeTarget.preset) {
KotlinNativePreset.linuxX64 -> linuxX64(
nativeTarget.targetName,