[Gradle, JS] Fix entry for webpack (with Configuration Avoidance broke)
This commit is contained in:
+10
-22
@@ -79,8 +79,6 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
|
|||||||
|
|
||||||
val compileKotlinTask = compilation.compileKotlinTask
|
val compileKotlinTask = compilation.compileKotlinTask
|
||||||
|
|
||||||
val dceOutputFileAppliers: MutableList<KotlinJsDce.(File) -> Unit> = mutableListOf()
|
|
||||||
|
|
||||||
buildVariants.all { buildVariant ->
|
buildVariants.all { buildVariant ->
|
||||||
val kind = buildVariant.kind
|
val kind = buildVariant.kind
|
||||||
val runTask = project.registerTask<KotlinWebpack>(
|
val runTask = project.registerTask<KotlinWebpack>(
|
||||||
@@ -109,9 +107,11 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
|
|||||||
|
|
||||||
when (kind) {
|
when (kind) {
|
||||||
BuildVariantKind.PRODUCTION -> {
|
BuildVariantKind.PRODUCTION -> {
|
||||||
dceOutputFileAppliers.add { file ->
|
// Breaking of Task Configuration Avoidance is not so critical
|
||||||
it.entry = file
|
// because this task is dependent on DCE task
|
||||||
}
|
it.entry = dceTaskProvider.get()
|
||||||
|
.destinationDir
|
||||||
|
.resolve(compileKotlinTask.outputFile.name)
|
||||||
it.resolveFromModulesFirst = true
|
it.resolveFromModulesFirst = true
|
||||||
it.dependsOn(dceTaskProvider)
|
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) {
|
if (kind == BuildVariantKind.DEVELOPMENT) {
|
||||||
target.runTask.dependsOn(runTask)
|
target.runTask.dependsOn(runTask)
|
||||||
project.registerTask<Task>(disambiguateCamelCased(RUN_TASK_NAME)) {
|
project.registerTask<Task>(disambiguateCamelCased(RUN_TASK_NAME)) {
|
||||||
@@ -149,8 +143,6 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
|
|||||||
|
|
||||||
val compileKotlinTask = compilation.compileKotlinTask
|
val compileKotlinTask = compilation.compileKotlinTask
|
||||||
|
|
||||||
val dceOutputFileAppliers: MutableList<KotlinJsDce.(File) -> Unit> = mutableListOf()
|
|
||||||
|
|
||||||
buildVariants.all { buildVariant ->
|
buildVariants.all { buildVariant ->
|
||||||
val kind = buildVariant.kind
|
val kind = buildVariant.kind
|
||||||
val webpackTask = project.registerTask<KotlinWebpack>(
|
val webpackTask = project.registerTask<KotlinWebpack>(
|
||||||
@@ -171,9 +163,11 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
|
|||||||
|
|
||||||
when (kind) {
|
when (kind) {
|
||||||
BuildVariantKind.PRODUCTION -> {
|
BuildVariantKind.PRODUCTION -> {
|
||||||
dceOutputFileAppliers.add { file ->
|
// Breaking of Task Configuration Avoidance is not so critical
|
||||||
it.entry = file
|
// because this task is dependent on DCE task
|
||||||
}
|
it.entry = dceTaskProvider.get()
|
||||||
|
.destinationDir
|
||||||
|
.resolve(compileKotlinTask.outputFile.name)
|
||||||
it.resolveFromModulesFirst = true
|
it.resolveFromModulesFirst = true
|
||||||
it.dependsOn(dceTaskProvider)
|
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) {
|
if (kind == BuildVariantKind.PRODUCTION) {
|
||||||
project.tasks.getByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).dependsOn(webpackTask)
|
project.tasks.getByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).dependsOn(webpackTask)
|
||||||
project.registerTask<Task>(disambiguateCamelCased(WEBPACK_TASK_NAME)) {
|
project.registerTask<Task>(disambiguateCamelCased(WEBPACK_TASK_NAME)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user