[Gradle, JS] Common webpack's configurations

This commit is contained in:
Ilya Goncharov
2019-10-21 19:16:14 +03:00
parent eb7fe6b0a4
commit e3ec37b14f
2 changed files with 16 additions and 6 deletions
@@ -33,6 +33,8 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
KotlinJsSubTarget(target, "browser"),
KotlinJsBrowserDsl {
private val commonWebpackConfigurations: MutableList<KotlinWebpack.() -> Unit> = mutableListOf()
private val commonRunConfigurations: MutableList<KotlinWebpack.() -> Unit> = mutableListOf()
private val dceConfigurations: MutableList<KotlinJsDce.() -> Unit> = mutableListOf()
private lateinit var buildVariants: NamedDomainObjectContainer<BuildVariant>
@@ -47,11 +49,11 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
}
override fun runTask(body: KotlinWebpack.() -> Unit) {
TODO()
commonRunConfigurations.add(body)
}
override fun webpackTask(body: KotlinWebpack.() -> Unit) {
TODO()
commonWebpackConfigurations.add(body)
}
@ExperimentalDce
@@ -116,6 +118,10 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
it.dependsOn(compileKotlinTask)
}
}
commonRunConfigurations.forEach { configure ->
it.configure()
}
}
dceTaskProvider.configure {
@@ -171,6 +177,10 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
it.dependsOn(compileKotlinTask)
}
}
commonWebpackConfigurations.forEach { configure ->
it.configure()
}
}
dceTaskProvider.configure {
@@ -198,8 +208,8 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
val kotlinTask = compilation.compileKotlinTask
return project.registerTask(dceTaskName) {
dceConfigurations.forEach { configuration ->
it.configuration()
dceConfigurations.forEach { configure ->
it.configure()
}
it.dependsOn(kotlinTask)
@@ -56,8 +56,8 @@ open class KotlinWebpack : DefaultTask(), RequiresNpmDependencies {
var entry: File? = null
get() = field ?: compilation.compileKotlinTask.outputFile
@Input
var resolveFromModulesFirst: Boolean = false
@get:Internal
internal var resolveFromModulesFirst: Boolean = false
@Suppress("unused")
val runtimeClasspath: FileCollection