From a0669538723680c3a7c77092ad208d6bbde79824 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 1 Sep 2020 20:21:41 +0300 Subject: [PATCH] Add application clause to the Extension --- .../ru/mipt/npm/gradle/KScienceExtension.kt | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt index e74d3b5..1f96e93 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt @@ -1,10 +1,10 @@ package ru.mipt.npm.gradle import org.gradle.api.Project -import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.extra -import org.gradle.kotlin.dsl.findPlugin -import org.gradle.kotlin.dsl.provideDelegate +import org.gradle.kotlin.dsl.* +import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension class KScienceExtension(val project: Project) { @@ -32,7 +32,7 @@ class KScienceExtension(val project: Project) { block: SerializationTargets.() -> Unit = {} ): Unit = project.run { plugins.apply("org.jetbrains.kotlin.plugin.serialization") - val artifactName = if(version.startsWith("0")){ + val artifactName = if (version.startsWith("0")) { "kotlinx-serialization-runtime" } else { "kotlinx-serialization-core" @@ -45,6 +45,25 @@ class KScienceExtension(val project: Project) { SerializationTargets(sourceSet, configuration).apply(block) } + /** + * Mark this module as an application module. JVM application should be enabled separately + */ + fun application() { + project.extensions.configure { + explicitApi = null + } + project.extensions.findByType()?.apply { + js { + binaries.executable() + } + } + project.extensions.findByType()?.apply { + js{ + binaries.executable() + } + } + } + /** * Activate publishing and configure it */