diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 466e359..28156b1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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" } diff --git a/src/main/kotlin/space/kscience/gradle/KScienceExtension.kt b/src/main/kotlin/space/kscience/gradle/KScienceExtension.kt index 66c9914..5e850db 100644 --- a/src/main/kotlin/space/kscience/gradle/KScienceExtension.kt +++ b/src/main/kotlin/space/kscience/gradle/KScienceExtension.kt @@ -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 = project.objects.property().apply { set(defaultJdkVersion) @@ -233,8 +233,8 @@ public abstract class KScienceExtension @Inject constructor(public val project: */ public fun useContextReceivers() { project.tasks.withType { - compilerOptions{ - freeCompilerArgs.add("-Xcontext-receivers") + compilerOptions { + freeCompilerArgs.add("-Xcontext-receivers") } } } @@ -287,46 +287,23 @@ public class KScienceNativeConfiguration(private val project: Project) { internal companion object { - private fun defaultNativeTargets(project: Project): Map { - val hostOs = System.getProperty("os.name") - - val targets = project.requestPropertyOrNull("publishing.targets") - - return when { - targets == "all" -> listOf( - KScienceNativeTarget.linuxX64, - KScienceNativeTarget.mingwX64, - KScienceNativeTarget.macosX64, - KScienceNativeTarget.macosArm64, - KScienceNativeTarget.iosX64, - KScienceNativeTarget.iosArm64, - KScienceNativeTarget.iosSimulatorArm64, - ) - - targets != null -> { + 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)) } } - - 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 } - } } @@ -364,7 +341,7 @@ public abstract class KScienceMppExtension @Inject constructor(project: Project) project.configure { 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 Project.registerKScienceExtension():T { +internal inline fun Project.registerKScienceExtension(): T { // extensions.findByType()?.let { return it } // return constructor(this).also { // extensions.add("kscience", it)