Gradle, js, dsl: use ConfigureUtil.configure for Groovy compatibility

This commit is contained in:
Sergey Rostov
2019-05-15 15:40:15 +03:00
parent 04a5b5a367
commit 2d51e2bca5
2 changed files with 10 additions and 16 deletions
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.gradle.targets.js.dsl
import groovy.lang.Closure
import org.gradle.util.ConfigureUtil
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack
@@ -15,8 +16,7 @@ interface KotlinJsTargetDsl {
fun browser(body: KotlinJsBrowserDsl.() -> Unit)
fun browser(fn: Closure<*>) {
browser {
fn.delegate = this
fn.call()
ConfigureUtil.configure(fn, this)
}
}
@@ -24,8 +24,7 @@ interface KotlinJsTargetDsl {
fun nodejs(body: KotlinJsNodeDsl.() -> Unit)
fun nodejs(fn: Closure<*>) {
nodejs {
fn.delegate = this
fn.call()
ConfigureUtil.configure(fn, this)
}
}
}
@@ -34,8 +33,7 @@ interface KotlinJsSubTargetDsl {
fun testTask(body: KotlinJsTest.() -> Unit)
fun testTask(fn: Closure<*>) {
testTask {
fn.delegate = this
fn.call()
ConfigureUtil.configure(fn, this)
}
}
}
@@ -44,16 +42,14 @@ interface KotlinJsBrowserDsl : KotlinJsSubTargetDsl {
fun runTask(body: KotlinWebpack.() -> Unit)
fun runTask(fn: Closure<*>) {
runTask {
fn.delegate = this
fn.call()
ConfigureUtil.configure(fn, this)
}
}
fun webpackTask(body: KotlinWebpack.() -> Unit)
fun webpackTask(fn: Closure<*>) {
testTask {
fn.delegate = this
fn.call()
ConfigureUtil.configure(fn, this)
}
}
}
@@ -10,6 +10,7 @@ import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.SkipWhenEmpty
import org.gradle.process.internal.DefaultProcessForkOptions
import org.gradle.util.ConfigureUtil
import org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessagesTestExecutionSpec
import org.jetbrains.kotlin.gradle.plugin.HasKotlinDependencies
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsPlugin
@@ -40,24 +41,21 @@ open class KotlinJsTest : KotlinTest(), RequiresNpmDependencies {
fun useNodeJs(body: KotlinNodeJsTestRunner.() -> Unit) = use(KotlinNodeJsTestRunner(project), body)
fun useNodeJs(fn: Closure<*>) {
useNodeJs {
fn.delegate = this
fn.call()
ConfigureUtil.configure(fn, this)
}
}
fun useMocha(body: KotlinMocha.() -> Unit) = use(KotlinMocha(project), body)
fun useMocha(fn: Closure<*>) {
useMocha {
fn.delegate = this
fn.call()
ConfigureUtil.configure(fn, this)
}
}
fun useKarma(body: KotlinKarma.() -> Unit) = use(KotlinKarma(project), body)
fun useKarma(fn: Closure<*>) {
useKarma {
fn.delegate = this
fn.call()
ConfigureUtil.configure(fn, this)
}
}