From 9fdb8ea25b52ef79002c680623354434733773ec Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 17 Jul 2019 16:04:39 +0300 Subject: [PATCH] Added basic native support --- build.gradle.kts | 3 +-- src/main/kotlin/Scientifik.kt | 8 +++--- .../kotlin/scientifik/ScientifikExtension.kt | 10 +++++++- .../kotlin/scientifik/ScientifikMPPlugin.kt | 25 ++++++++++++++++--- .../scientifik/ScientifikPublishPlugin.kt | 2 +- 5 files changed, 36 insertions(+), 12 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 6d851ca..15b3283 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,12 +3,11 @@ import java.util.* plugins { `kotlin-dsl` `maven-publish` -// id("com.gradle.plugin-publish") version "0.10.1" id("com.jfrog.bintray") version "1.8.4" } group = "scientifik" -version = "0.1.3" +version = "0.1.4" repositories { gradlePluginPortal() diff --git a/src/main/kotlin/Scientifik.kt b/src/main/kotlin/Scientifik.kt index 617b2e6..e419764 100644 --- a/src/main/kotlin/Scientifik.kt +++ b/src/main/kotlin/Scientifik.kt @@ -2,8 +2,8 @@ * Build constants */ object Scientifik { - val ioVersion = "0.1.10" - val coroutinesVersion = "1.2.2" - val atomicfuVersion = "0.12.9" - val serializationVersion = "0.11.1" + const val ioVersion = "0.1.11" + const val coroutinesVersion = "1.2.2" + const val atomicfuVersion = "0.12.9" + const val serializationVersion = "0.11.1" } diff --git a/src/main/kotlin/scientifik/ScientifikExtension.kt b/src/main/kotlin/scientifik/ScientifikExtension.kt index eb19771..7c595e0 100644 --- a/src/main/kotlin/scientifik/ScientifikExtension.kt +++ b/src/main/kotlin/scientifik/ScientifikExtension.kt @@ -1,8 +1,16 @@ package scientifik +import org.gradle.api.Project +import org.gradle.kotlin.dsl.create +import org.gradle.kotlin.dsl.findByType + open class ScientifikExtension { var githubProject: String? = null var vcs: String? = null var bintrayRepo: String? = null var kdoc: Boolean = true -} \ No newline at end of file + var enableNative = false +} + +internal val Project.scientifik: ScientifikExtension + get() = extensions.findByType() ?: extensions.create("scientifik") \ No newline at end of file diff --git a/src/main/kotlin/scientifik/ScientifikMPPlugin.kt b/src/main/kotlin/scientifik/ScientifikMPPlugin.kt index 3aa195d..cf6722d 100644 --- a/src/main/kotlin/scientifik/ScientifikMPPlugin.kt +++ b/src/main/kotlin/scientifik/ScientifikMPPlugin.kt @@ -2,16 +2,15 @@ package scientifik import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.getValue -import org.gradle.kotlin.dsl.getting -import org.gradle.kotlin.dsl.invoke +import org.gradle.kotlin.dsl.* import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension open class ScientifikMPPlugin : Plugin { override fun apply(project: Project) { project.plugins.apply("org.jetbrains.kotlin.multiplatform") + val extension = project.scientifik + project.configure { jvm { compilations.all { @@ -31,6 +30,11 @@ open class ScientifikMPPlugin : Plugin { } } + if(extension.enableNative){ + linuxX64() + mingwX64() + } + sourceSets.invoke { val commonMain by getting { dependencies { @@ -64,12 +68,25 @@ open class ScientifikMPPlugin : Plugin { implementation(kotlin("test-js")) } } + + if(extension.enableNative){ + val native by creating { + dependsOn(commonMain) + } + mingwX64().compilations["main"].defaultSourceSet { + dependsOn(native) + } + linuxX64().compilations["main"].defaultSourceSet { + dependsOn(native) + } + } } targets.all { sourceSets.all { languageSettings.apply{ progressiveMode = true + this. enableLanguageFeature("InlineClasses") useExperimentalAnnotation("ExperimentalUnsignedType") } diff --git a/src/main/kotlin/scientifik/ScientifikPublishPlugin.kt b/src/main/kotlin/scientifik/ScientifikPublishPlugin.kt index 553fa15..159d71d 100644 --- a/src/main/kotlin/scientifik/ScientifikPublishPlugin.kt +++ b/src/main/kotlin/scientifik/ScientifikPublishPlugin.kt @@ -43,7 +43,7 @@ open class ScientifikPublishPlugin : Plugin { override fun apply(project: Project) { project.plugins.apply("maven-publish") - val extension = project.extensions.create("scientifik") + val extension = project.scientifik if (extension.kdoc) { project.plugins.apply("org.jetbrains.dokka")