Conditional configuration for serialization
This commit is contained in:
parent
ab106cab82
commit
91d0bd9d2e
@ -20,6 +20,7 @@ val kotlinVersion = "1.3.50-eap-5"
|
||||
// Add plugins used in buildSrc as dependencies, also we should specify version only here
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
||||
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
|
||||
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7")
|
||||
implementation("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4")
|
||||
implementation("org.jetbrains.dokka:dokka-gradle-plugin:0.9.18")
|
||||
|
@ -9,7 +9,8 @@ open class ScientifikExtension {
|
||||
var vcs: String? = null
|
||||
var bintrayRepo: String? = null
|
||||
var kdoc: Boolean = true
|
||||
var enableNative = false
|
||||
var native = false
|
||||
var serialization = false
|
||||
}
|
||||
|
||||
internal val Project.scientifik: ScientifikExtension
|
||||
|
@ -1,5 +1,6 @@
|
||||
package scientifik
|
||||
|
||||
import Scientifik
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.*
|
||||
@ -7,10 +8,20 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
|
||||
open class ScientifikMPPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
project.plugins.apply("org.jetbrains.kotlin.multiplatform")
|
||||
|
||||
val extension = project.scientifik
|
||||
|
||||
project.plugins.apply("org.jetbrains.kotlin.multiplatform")
|
||||
project.plugins.apply("kotlinx-serialization")
|
||||
|
||||
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")
|
||||
maven("https://dl.bintray.com/mipt-npm/scientifik")
|
||||
}
|
||||
|
||||
project.configure<KotlinMultiplatformExtension> {
|
||||
jvm {
|
||||
compilations.all {
|
||||
@ -30,7 +41,7 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
}
|
||||
}
|
||||
|
||||
if(extension.enableNative){
|
||||
if (extension.native) {
|
||||
linuxX64()
|
||||
mingwX64()
|
||||
}
|
||||
@ -39,6 +50,11 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
api(kotlin("stdlib"))
|
||||
project.afterEvaluate {
|
||||
if (extension.serialization) {
|
||||
api("org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Scientifik.serializationVersion}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val commonTest by getting {
|
||||
@ -69,7 +85,8 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
}
|
||||
}
|
||||
|
||||
if(extension.enableNative){
|
||||
project.afterEvaluate {
|
||||
if (extension.native) {
|
||||
val native by creating {
|
||||
dependsOn(commonMain)
|
||||
}
|
||||
@ -81,12 +98,12 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
targets.all {
|
||||
sourceSets.all {
|
||||
languageSettings.apply {
|
||||
progressiveMode = true
|
||||
this.
|
||||
enableLanguageFeature("InlineClasses")
|
||||
useExperimentalAnnotation("ExperimentalUnsignedType")
|
||||
}
|
||||
|
@ -45,12 +45,12 @@ open class ScientifikPublishPlugin : Plugin<Project> {
|
||||
project.plugins.apply("maven-publish")
|
||||
val extension = project.scientifik
|
||||
|
||||
project.afterEvaluate {
|
||||
|
||||
if (extension.kdoc) {
|
||||
project.plugins.apply("org.jetbrains.dokka")
|
||||
}
|
||||
|
||||
project.afterEvaluate {
|
||||
|
||||
val bintrayRepo = project.bintrayRepo
|
||||
val vcs = project.vcs
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user