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