publish all targets by default

This commit is contained in:
Alexander Nozik 2024-12-21 09:02:58 +03:00
parent e1c946cd8f
commit d12497ebe2
2 changed files with 21 additions and 43 deletions

View File

@ -95,6 +95,7 @@ kotlinx-serialization-hocon = { module = "org.jetbrains.kotlinx:kotlinx-serializ
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
kotlinx-serialization-properties = { module = "org.jetbrains.kotlinx:kotlinx-serialization-properties", version.ref = "kotlinx-serialization" }
kotlinx-serialization-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf", version.ref = "kotlinx-serialization" }
kotlinx-browser = "org.jetbrains.kotlinx:kotlinx-browser:0.3"
ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
ktor-bom = { module = "io.ktor:ktor-bom", version.ref = "ktor" }
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }

View File

@ -54,7 +54,7 @@ public val Project.isInDevelopment: Boolean
private const val defaultJdkVersion = 17
public abstract class KScienceExtension @Inject constructor(public val project: Project): ExtensionAware {
public abstract class KScienceExtension @Inject constructor(public val project: Project) : ExtensionAware {
public val jdkVersionProperty: Property<Int> = project.objects.property<Int>().apply {
set(defaultJdkVersion)
@ -233,7 +233,7 @@ public abstract class KScienceExtension @Inject constructor(public val project:
*/
public fun useContextReceivers() {
project.tasks.withType<KotlinCompile> {
compilerOptions{
compilerOptions {
freeCompilerArgs.add("-Xcontext-receivers")
}
}
@ -287,13 +287,10 @@ public class KScienceNativeConfiguration(private val project: Project) {
internal companion object {
private fun defaultNativeTargets(project: Project): Map<KotlinNativePreset, KScienceNativeTarget> {
val hostOs = System.getProperty("os.name")
val targets = project.requestPropertyOrNull("publishing.targets")
return when {
targets == "all" -> listOf(
private fun defaultNativeTargets(project: Project): Map<KotlinNativePreset, KScienceNativeTarget> =
when (val targets = project.requestPropertyOrNull("publishing.targets")) {
null -> {
listOf(
KScienceNativeTarget.linuxX64,
KScienceNativeTarget.mingwX64,
KScienceNativeTarget.macosX64,
@ -302,32 +299,12 @@ public class KScienceNativeConfiguration(private val project: Project) {
KScienceNativeTarget.iosArm64,
KScienceNativeTarget.iosSimulatorArm64,
)
targets != null -> {
}
else -> {
targets.split(",").map { KScienceNativeTarget(KotlinNativePreset.valueOf(it)) }
}
hostOs.startsWith("Windows") -> listOf(
KScienceNativeTarget.linuxX64,
KScienceNativeTarget.mingwX64
)
hostOs == "Mac OS X" -> listOf(
KScienceNativeTarget.macosX64,
KScienceNativeTarget.macosArm64,
KScienceNativeTarget.iosX64,
KScienceNativeTarget.iosArm64,
KScienceNativeTarget.iosSimulatorArm64,
)
hostOs == "Linux" -> listOf(KScienceNativeTarget.linuxX64)
else -> {
emptyList()
}
}.associateBy { it.preset }
}
}
internal var targets: Map<KotlinNativePreset, KScienceNativeTarget> = defaultNativeTargets(project)
@ -364,7 +341,7 @@ public abstract class KScienceMppExtension @Inject constructor(project: Project)
project.configure<KotlinMultiplatformExtension> {
jvm {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions{
compilerOptions {
freeCompilerArgs.addAll(defaultKotlinJvmArgs)
}
block()
@ -458,7 +435,7 @@ public abstract class KScienceMppExtension @Inject constructor(project: Project)
) {
js {
browser {
commonWebpackConfig{
commonWebpackConfig {
outputFileName = bundleName
}
browserConfig()
@ -537,7 +514,7 @@ public abstract class KScienceMppExtension @Inject constructor(project: Project)
}
internal inline fun <reified T : KScienceExtension> Project.registerKScienceExtension():T {
internal inline fun <reified T : KScienceExtension> Project.registerKScienceExtension(): T {
// extensions.findByType<T>()?.let { return it }
// return constructor(this).also {
// extensions.add("kscience", it)