From a1263e445e7e596e659ac3399b54983cf6c537ac Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Tue, 25 Feb 2020 16:35:55 +0300 Subject: [PATCH] [Gradle, JS] Add redundant methods for single js plugin --- .../gradle/dsl/KotlinProjectExtension.kt | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt index 20a25125bab..947abde7346 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt @@ -101,6 +101,7 @@ open class KotlinJsProjectExtension : internal var _target: KotlinJsTargetDsl? = null private set + @Deprecated("Use js() instead", ReplaceWith("js()")) override var target: KotlinJsTargetDsl get() { if (_target == null) { @@ -116,8 +117,8 @@ open class KotlinJsProjectExtension : open fun js( compiler: KotlinJsCompilerType = defaultJsCompilerType, - body: KotlinJsTargetDsl.() -> Unit - ) { + body: KotlinJsTargetDsl.() -> Unit = { } + ): KotlinJsTargetDsl { if (_target == null) { val target: KotlinJsTargetDsl = when (compiler) { LEGACY -> legacyPreset @@ -145,12 +146,25 @@ open class KotlinJsProjectExtension : } target.run(body) + + return target } - open fun js( - body: KotlinJsTargetDsl.() -> Unit + fun js( + body: KotlinJsTargetDsl.() -> Unit = { } ) = js(compiler = defaultJsCompilerType, body = body) + fun js() = js { } + + fun js(compiler: KotlinJsCompilerType, configure: Closure<*>) = + js(compiler = compiler) { + ConfigureUtil.configure(configure, this) + } + + fun js(configure: Closure<*>) = js { + ConfigureUtil.configure(configure, this) + } + @Deprecated("Use js instead", ReplaceWith("js(body)")) open fun target(body: KotlinJsTargetDsl.() -> Unit) = js(body)