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-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-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-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" } ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
ktor-bom = { module = "io.ktor:ktor-bom", version.ref = "ktor" } ktor-bom = { module = "io.ktor:ktor-bom", version.ref = "ktor" }
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" } 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 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 { public val jdkVersionProperty: Property<Int> = project.objects.property<Int>().apply {
set(defaultJdkVersion) set(defaultJdkVersion)
@ -233,8 +233,8 @@ public abstract class KScienceExtension @Inject constructor(public val project:
*/ */
public fun useContextReceivers() { public fun useContextReceivers() {
project.tasks.withType<KotlinCompile> { project.tasks.withType<KotlinCompile> {
compilerOptions{ compilerOptions {
freeCompilerArgs.add("-Xcontext-receivers") freeCompilerArgs.add("-Xcontext-receivers")
} }
} }
} }
@ -287,46 +287,23 @@ 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): Map<KotlinNativePreset, KScienceNativeTarget> =
val hostOs = System.getProperty("os.name") when (val targets = project.requestPropertyOrNull("publishing.targets")) {
null -> {
val targets = project.requestPropertyOrNull("publishing.targets") listOf(
KScienceNativeTarget.linuxX64,
return when { KScienceNativeTarget.mingwX64,
targets == "all" -> listOf( KScienceNativeTarget.macosX64,
KScienceNativeTarget.linuxX64, KScienceNativeTarget.macosArm64,
KScienceNativeTarget.mingwX64, KScienceNativeTarget.iosX64,
KScienceNativeTarget.macosX64, KScienceNativeTarget.iosArm64,
KScienceNativeTarget.macosArm64, KScienceNativeTarget.iosSimulatorArm64,
KScienceNativeTarget.iosX64, )
KScienceNativeTarget.iosArm64, }
KScienceNativeTarget.iosSimulatorArm64, else -> {
)
targets != null -> {
targets.split(",").map { KScienceNativeTarget(KotlinNativePreset.valueOf(it)) } 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 } }.associateBy { it.preset }
}
} }
@ -364,7 +341,7 @@ public abstract class KScienceMppExtension @Inject constructor(project: Project)
project.configure<KotlinMultiplatformExtension> { project.configure<KotlinMultiplatformExtension> {
jvm { jvm {
@OptIn(ExperimentalKotlinGradlePluginApi::class) @OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions{ compilerOptions {
freeCompilerArgs.addAll(defaultKotlinJvmArgs) freeCompilerArgs.addAll(defaultKotlinJvmArgs)
} }
block() block()
@ -458,7 +435,7 @@ public abstract class KScienceMppExtension @Inject constructor(project: Project)
) { ) {
js { js {
browser { browser {
commonWebpackConfig{ commonWebpackConfig {
outputFileName = bundleName outputFileName = bundleName
} }
browserConfig() 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 } // extensions.findByType<T>()?.let { return it }
// return constructor(this).also { // return constructor(this).also {
// extensions.add("kscience", it) // extensions.add("kscience", it)