[Gradle, JS] Configure requires NPM dependencies inside rootPackageJson
^KT-34014 fixed ^KT-49505 fixed
This commit is contained in:
+26
-14
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.gradle.targets.js.yarn
|
|||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.plugins.BasePlugin
|
import org.gradle.api.plugins.BasePlugin
|
||||||
import org.jetbrains.kotlin.gradle.plugin.whenEvaluated
|
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.MultiplePluginDeclarationDetector
|
import org.jetbrains.kotlin.gradle.targets.js.MultiplePluginDeclarationDetector
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
|
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies
|
import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies
|
||||||
@@ -45,6 +44,19 @@ open class YarnPlugin : Plugin<Project> {
|
|||||||
task.description = "Create root package.json"
|
task.description = "Create root package.json"
|
||||||
|
|
||||||
task.mustRunAfter(rootClean)
|
task.mustRunAfter(rootClean)
|
||||||
|
|
||||||
|
// Yes, we need to break Task Configuration Avoidance here
|
||||||
|
// In case when we need to create package.json's files and execute kotlinNpmInstall,
|
||||||
|
// We need to configure all RequiresNpmDependencies tasks to install them,
|
||||||
|
// Because we need to persist yarn.lock
|
||||||
|
// We execute this block in configure phase of rootPackageJson to be sure,
|
||||||
|
// That Task Configuration Avoidance will not be broken for tasks not related with NPM installing
|
||||||
|
// https://youtrack.jetbrains.com/issue/KT-48241
|
||||||
|
project.allprojects
|
||||||
|
.forEach {
|
||||||
|
it.tasks.implementing(RequiresNpmDependencies::class)
|
||||||
|
.forEach {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val kotlinNpmInstall = tasks.named(KotlinNpmInstallTask.NAME)
|
val kotlinNpmInstall = tasks.named(KotlinNpmInstallTask.NAME)
|
||||||
@@ -65,19 +77,19 @@ open class YarnPlugin : Plugin<Project> {
|
|||||||
it.dependsOn(packageJsonUmbrella)
|
it.dependsOn(packageJsonUmbrella)
|
||||||
}
|
}
|
||||||
|
|
||||||
project.allprojects
|
// project.allprojects
|
||||||
.forEach {
|
// .forEach {
|
||||||
val fn: (Project) -> Unit = {
|
// val fn: (Project) -> Unit = {
|
||||||
it.tasks.implementing(RequiresNpmDependencies::class).all {}
|
// it.tasks.implementing(RequiresNpmDependencies::class).all {}
|
||||||
}
|
// }
|
||||||
if (it.state.executed) {
|
// if (it.state.executed) {
|
||||||
fn(it)
|
// fn(it)
|
||||||
} else {
|
// } else {
|
||||||
it.afterEvaluate {
|
// it.afterEvaluate {
|
||||||
fn(it)
|
// fn(it)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
val storeYarnLock = tasks.register("kotlinStoreYarnLock", YarnLockCopyTask::class.java) {
|
val storeYarnLock = tasks.register("kotlinStoreYarnLock", YarnLockCopyTask::class.java) {
|
||||||
it.dependsOn(kotlinNpmInstall)
|
it.dependsOn(kotlinNpmInstall)
|
||||||
|
|||||||
Reference in New Issue
Block a user