2019-06-28 16:22:11 +03:00
|
|
|
package scientifik
|
|
|
|
|
2019-07-20 20:39:26 +03:00
|
|
|
import Scientifik
|
2019-06-28 16:22:11 +03:00
|
|
|
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) {
|
2019-07-20 20:39:26 +03:00
|
|
|
val extension = project.scientifik
|
|
|
|
|
2019-06-28 16:22:11 +03:00
|
|
|
project.plugins.apply("org.jetbrains.kotlin.multiplatform")
|
2019-07-20 20:39:26 +03:00
|
|
|
project.plugins.apply("kotlinx-serialization")
|
2019-07-21 17:40:08 +03:00
|
|
|
project.plugins.apply("kotlinx-atomicfu")
|
2019-06-28 16:22:11 +03:00
|
|
|
|
2019-07-20 20:39:26 +03:00
|
|
|
project.repositories {
|
|
|
|
mavenCentral()
|
|
|
|
jcenter()
|
|
|
|
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
|
|
|
maven("https://kotlin.bintray.com/kotlinx")
|
|
|
|
maven("https://dl.bintray.com/mipt-npm/dev")
|
|
|
|
}
|
2019-07-17 16:04:39 +03:00
|
|
|
|
2019-06-28 16:22:11 +03:00
|
|
|
project.configure<KotlinMultiplatformExtension> {
|
|
|
|
jvm {
|
|
|
|
compilations.all {
|
|
|
|
kotlinOptions {
|
|
|
|
jvmTarget = "1.8"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-21 17:40:08 +03:00
|
|
|
js {
|
|
|
|
browser {}
|
2019-06-28 16:22:11 +03:00
|
|
|
}
|
|
|
|
|
2019-07-20 20:39:26 +03:00
|
|
|
if (extension.native) {
|
2019-07-17 16:04:39 +03:00
|
|
|
linuxX64()
|
|
|
|
mingwX64()
|
|
|
|
}
|
|
|
|
|
2019-06-28 16:22:11 +03:00
|
|
|
sourceSets.invoke {
|
|
|
|
val commonMain by getting {
|
|
|
|
dependencies {
|
|
|
|
api(kotlin("stdlib"))
|
2019-07-20 20:39:26 +03:00
|
|
|
project.afterEvaluate {
|
|
|
|
if (extension.serialization) {
|
2019-07-21 17:40:08 +03:00
|
|
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Scientifik.serializationVersion}")
|
|
|
|
}
|
|
|
|
if(extension.atomicfu){
|
|
|
|
implementation("org.jetbrains.kotlinx:atomicfu-common:${Scientifik.atomicfuVersion}")
|
|
|
|
}
|
|
|
|
if(extension.io){
|
2019-07-21 21:11:40 +03:00
|
|
|
api("org.jetbrains.kotlinx:kotlinx-io:${Scientifik.ioVersion}")
|
2019-07-20 20:39:26 +03:00
|
|
|
}
|
|
|
|
}
|
2019-06-28 16:22:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
val commonTest by getting {
|
|
|
|
dependencies {
|
|
|
|
implementation(kotlin("test-common"))
|
|
|
|
implementation(kotlin("test-annotations-common"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
val jvmMain by getting {
|
|
|
|
dependencies {
|
|
|
|
api(kotlin("stdlib-jdk8"))
|
2019-07-22 18:57:47 +03:00
|
|
|
project.afterEvaluate {
|
|
|
|
if (extension.atomicfu) {
|
|
|
|
implementation("org.jetbrains.kotlinx:atomicfu:${Scientifik.atomicfuVersion}")
|
|
|
|
}
|
|
|
|
if (extension.io) {
|
|
|
|
api("org.jetbrains.kotlinx:kotlinx-io-jvm:${Scientifik.ioVersion}")
|
|
|
|
}
|
2019-07-21 17:40:08 +03:00
|
|
|
}
|
2019-06-28 16:22:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
val jvmTest by getting {
|
|
|
|
dependencies {
|
|
|
|
implementation(kotlin("test"))
|
|
|
|
implementation(kotlin("test-junit"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
val jsMain by getting {
|
|
|
|
dependencies {
|
|
|
|
api(kotlin("stdlib-js"))
|
2019-07-22 18:57:47 +03:00
|
|
|
project.afterEvaluate {
|
|
|
|
if (extension.atomicfu) {
|
|
|
|
implementation("org.jetbrains.kotlinx:atomicfu-common-js:${Scientifik.atomicfuVersion}")
|
|
|
|
}
|
|
|
|
if (extension.io) {
|
|
|
|
api("org.jetbrains.kotlinx:kotlinx-io-js:${Scientifik.ioVersion}")
|
|
|
|
}
|
2019-07-21 17:40:08 +03:00
|
|
|
}
|
2019-06-28 16:22:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
val jsTest by getting {
|
|
|
|
dependencies {
|
|
|
|
implementation(kotlin("test-js"))
|
|
|
|
}
|
|
|
|
}
|
2019-07-17 16:04:39 +03:00
|
|
|
|
2019-07-20 20:39:26 +03:00
|
|
|
project.afterEvaluate {
|
|
|
|
if (extension.native) {
|
|
|
|
val native by creating {
|
|
|
|
dependsOn(commonMain)
|
|
|
|
}
|
|
|
|
mingwX64().compilations["main"].defaultSourceSet {
|
|
|
|
dependsOn(native)
|
|
|
|
}
|
|
|
|
linuxX64().compilations["main"].defaultSourceSet {
|
|
|
|
dependsOn(native)
|
|
|
|
}
|
2019-07-17 16:04:39 +03:00
|
|
|
}
|
|
|
|
}
|
2019-06-28 16:22:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
targets.all {
|
|
|
|
sourceSets.all {
|
2019-07-20 20:39:26 +03:00
|
|
|
languageSettings.apply {
|
2019-06-28 16:22:11 +03:00
|
|
|
progressiveMode = true
|
|
|
|
enableLanguageFeature("InlineClasses")
|
|
|
|
useExperimentalAnnotation("ExperimentalUnsignedType")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|