Add application clause to the Extension

This commit is contained in:
Alexander Nozik 2020-09-01 20:21:41 +03:00
parent 02cd531800
commit a066953872

View File

@ -1,10 +1,10 @@
package ru.mipt.npm.gradle package ru.mipt.npm.gradle
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.*
import org.gradle.kotlin.dsl.extra import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
import org.gradle.kotlin.dsl.findPlugin import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.gradle.kotlin.dsl.provideDelegate import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
class KScienceExtension(val project: Project) { class KScienceExtension(val project: Project) {
@ -32,7 +32,7 @@ class KScienceExtension(val project: Project) {
block: SerializationTargets.() -> Unit = {} block: SerializationTargets.() -> Unit = {}
): Unit = project.run { ): Unit = project.run {
plugins.apply("org.jetbrains.kotlin.plugin.serialization") plugins.apply("org.jetbrains.kotlin.plugin.serialization")
val artifactName = if(version.startsWith("0")){ val artifactName = if (version.startsWith("0")) {
"kotlinx-serialization-runtime" "kotlinx-serialization-runtime"
} else { } else {
"kotlinx-serialization-core" "kotlinx-serialization-core"
@ -45,6 +45,25 @@ class KScienceExtension(val project: Project) {
SerializationTargets(sourceSet, configuration).apply(block) SerializationTargets(sourceSet, configuration).apply(block)
} }
/**
* Mark this module as an application module. JVM application should be enabled separately
*/
fun application() {
project.extensions.configure<KotlinProjectExtension> {
explicitApi = null
}
project.extensions.findByType<KotlinJsProjectExtension>()?.apply {
js {
binaries.executable()
}
}
project.extensions.findByType<KotlinMultiplatformExtension>()?.apply {
js{
binaries.executable()
}
}
}
/** /**
* Activate publishing and configure it * Activate publishing and configure it
*/ */