2019-06-28 16:22:11 +03:00
|
|
|
package scientifik
|
|
|
|
|
|
|
|
import org.gradle.api.Plugin
|
|
|
|
import org.gradle.api.Project
|
2019-07-17 16:04:39 +03:00
|
|
|
import org.gradle.kotlin.dsl.*
|
2019-06-28 16:22:11 +03:00
|
|
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
|
|
|
|
|
|
|
open class ScientifikMPPlugin : Plugin<Project> {
|
|
|
|
override fun apply(project: Project) {
|
|
|
|
project.plugins.apply("org.jetbrains.kotlin.multiplatform")
|
|
|
|
|
2019-07-17 16:04:39 +03:00
|
|
|
val extension = project.scientifik
|
|
|
|
|
2019-06-28 16:22:11 +03:00
|
|
|
project.configure<KotlinMultiplatformExtension> {
|
|
|
|
jvm {
|
|
|
|
compilations.all {
|
|
|
|
kotlinOptions {
|
|
|
|
jvmTarget = "1.8"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
js {
|
|
|
|
compilations.all {
|
|
|
|
kotlinOptions {
|
|
|
|
sourceMap = true
|
|
|
|
sourceMapEmbedSources = "always"
|
|
|
|
moduleKind = "umd"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-17 16:04:39 +03:00
|
|
|
if(extension.enableNative){
|
|
|
|
linuxX64()
|
|
|
|
mingwX64()
|
|
|
|
}
|
|
|
|
|
2019-06-28 16:22:11 +03:00
|
|
|
sourceSets.invoke {
|
|
|
|
val commonMain by getting {
|
|
|
|
dependencies {
|
|
|
|
api(kotlin("stdlib"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
val commonTest by getting {
|
|
|
|
dependencies {
|
|
|
|
implementation(kotlin("test-common"))
|
|
|
|
implementation(kotlin("test-annotations-common"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
val jvmMain by getting {
|
|
|
|
dependencies {
|
|
|
|
api(kotlin("stdlib-jdk8"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
val jvmTest by getting {
|
|
|
|
dependencies {
|
|
|
|
implementation(kotlin("test"))
|
|
|
|
implementation(kotlin("test-junit"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
val jsMain by getting {
|
|
|
|
dependencies {
|
|
|
|
api(kotlin("stdlib-js"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
val jsTest by getting {
|
|
|
|
dependencies {
|
|
|
|
implementation(kotlin("test-js"))
|
|
|
|
}
|
|
|
|
}
|
2019-07-17 16:04:39 +03:00
|
|
|
|
|
|
|
if(extension.enableNative){
|
|
|
|
val native by creating {
|
|
|
|
dependsOn(commonMain)
|
|
|
|
}
|
|
|
|
mingwX64().compilations["main"].defaultSourceSet {
|
|
|
|
dependsOn(native)
|
|
|
|
}
|
|
|
|
linuxX64().compilations["main"].defaultSourceSet {
|
|
|
|
dependsOn(native)
|
|
|
|
}
|
|
|
|
}
|
2019-06-28 16:22:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
targets.all {
|
|
|
|
sourceSets.all {
|
|
|
|
languageSettings.apply{
|
|
|
|
progressiveMode = true
|
2019-07-17 16:04:39 +03:00
|
|
|
this.
|
2019-06-28 16:22:11 +03:00
|
|
|
enableLanguageFeature("InlineClasses")
|
|
|
|
useExperimentalAnnotation("ExperimentalUnsignedType")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|