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