[Gradle, JS] Add possibility to configure dce task
This commit is contained in:
+8
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.gradle.targets.js.KotlinJsReportAggregatingTestRun
|
||||
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
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinJsDce
|
||||
|
||||
interface KotlinJsTargetDsl {
|
||||
fun browser() = browser { }
|
||||
@@ -59,6 +60,13 @@ interface KotlinJsBrowserDsl : KotlinJsSubTargetDsl {
|
||||
ConfigureUtil.configure(fn, this)
|
||||
}
|
||||
}
|
||||
|
||||
fun dceTask(body: KotlinJsDce.() -> Unit)
|
||||
fun dceTask(fn: Closure<*>) {
|
||||
dceTask {
|
||||
ConfigureUtil.configure(fn, this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface KotlinJsNodeDsl : KotlinJsSubTargetDsl {
|
||||
|
||||
+9
@@ -31,6 +31,7 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
|
||||
KotlinJsSubTarget(target, "browser"),
|
||||
KotlinJsBrowserDsl {
|
||||
|
||||
private val dceConfigurations: MutableList<KotlinJsDce.() -> Unit> = mutableListOf()
|
||||
private val dceWebpackEntryAppliers: MutableList<KotlinJsDce.(File) -> Unit> = mutableListOf()
|
||||
private lateinit var dceTaskProvider: TaskProvider<KotlinJsDce>
|
||||
|
||||
@@ -55,6 +56,10 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
|
||||
(project.tasks.getByName(webpackTaskName) as KotlinWebpack).body()
|
||||
}
|
||||
|
||||
override fun dceTask(body: KotlinJsDce.() -> Unit) {
|
||||
dceConfigurations.add(body)
|
||||
}
|
||||
|
||||
override fun configureRun(compilation: KotlinJsCompilation) {
|
||||
|
||||
val project = compilation.target.project
|
||||
@@ -172,6 +177,10 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
|
||||
val kotlinTask = compilation.compileKotlinTask
|
||||
|
||||
return project.registerTask<KotlinJsDce>(dceTaskName) {
|
||||
dceConfigurations.forEach { configuration ->
|
||||
it.configuration()
|
||||
}
|
||||
|
||||
it.dependsOn(kotlinTask)
|
||||
|
||||
it.classpath = project.configurations.getByName(compilation.compileDependencyConfigurationName)
|
||||
|
||||
Reference in New Issue
Block a user