[Gradle, JS] Fix entry for webpack (with Configuration Avoidance broke)

This commit is contained in:
Ilya Goncharov
2019-10-30 15:11:01 +03:00
parent 6f91c0e679
commit 08f9dd2aea
@@ -79,8 +79,6 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
val compileKotlinTask = compilation.compileKotlinTask
val dceOutputFileAppliers: MutableList<KotlinJsDce.(File) -> Unit> = mutableListOf()
buildVariants.all { buildVariant ->
val kind = buildVariant.kind
val runTask = project.registerTask<KotlinWebpack>(
@@ -109,9 +107,11 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
when (kind) {
BuildVariantKind.PRODUCTION -> {
dceOutputFileAppliers.add { file ->
it.entry = file
}
// Breaking of Task Configuration Avoidance is not so critical
// because this task is dependent on DCE task
it.entry = dceTaskProvider.get()
.destinationDir
.resolve(compileKotlinTask.outputFile.name)
it.resolveFromModulesFirst = true
it.dependsOn(dceTaskProvider)
}
@@ -125,12 +125,6 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
}
}
dceTaskProvider.configure {
dceOutputFileAppliers.forEach { dceOutputFileApplier ->
it.dceOutputFileApplier(it.destinationDir.resolve(compileKotlinTask.outputFile.name))
}
}
if (kind == BuildVariantKind.DEVELOPMENT) {
target.runTask.dependsOn(runTask)
project.registerTask<Task>(disambiguateCamelCased(RUN_TASK_NAME)) {
@@ -149,8 +143,6 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
val compileKotlinTask = compilation.compileKotlinTask
val dceOutputFileAppliers: MutableList<KotlinJsDce.(File) -> Unit> = mutableListOf()
buildVariants.all { buildVariant ->
val kind = buildVariant.kind
val webpackTask = project.registerTask<KotlinWebpack>(
@@ -171,9 +163,11 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
when (kind) {
BuildVariantKind.PRODUCTION -> {
dceOutputFileAppliers.add { file ->
it.entry = file
}
// Breaking of Task Configuration Avoidance is not so critical
// because this task is dependent on DCE task
it.entry = dceTaskProvider.get()
.destinationDir
.resolve(compileKotlinTask.outputFile.name)
it.resolveFromModulesFirst = true
it.dependsOn(dceTaskProvider)
}
@@ -187,12 +181,6 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
}
}
dceTaskProvider.configure {
dceOutputFileAppliers.forEach { dceOutputFileApplier ->
it.dceOutputFileApplier(it.destinationDir.resolve(compileKotlinTask.outputFile.name))
}
}
if (kind == BuildVariantKind.PRODUCTION) {
project.tasks.getByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).dependsOn(webpackTask)
project.registerTask<Task>(disambiguateCamelCased(WEBPACK_TASK_NAME)) {