Do not suppress NPM related tasks, but be aware about checking of them in task graph

This commit is contained in:
Ilya Goncharov
2023-01-10 21:21:56 +01:00
committed by Space Team
parent 887547c445
commit d7c31f79a8
7 changed files with 0 additions and 47 deletions
@@ -11,7 +11,6 @@ import org.gradle.api.tasks.TaskProvider
/* This file is solely needed to suppress implicit dependencies on npm and yarn tasks registered by Kotlin Gradle Plugin */
private val rootNpmRelatedTasks = setOf("kotlinNpmInstall", "kotlinStoreYarnLock")
private val ownNpmRelatedTasks = setOf("jsGenerateExternalsIntegrated", "irGenerateExternalsIntegrated", "wasmGenerateExternalsIntegrated")
private val forbidImplicitDependOnNpmRelatedTasks = setOf(
"jsPackageJson",
@@ -27,40 +26,6 @@ private val forbidImplicitDependOnNpmRelatedTasks = setOf(
)
private val allowImplicitDependOnNpmForTasks = setOf("compileTestKotlinJs", "compileTestKotlinWasm")
/**
* Kotlin JS gradle plugin implicitly define dependency to installing NPM and Yarn
* https://youtrack.jetbrains.com/issue/KT-53687/Dont-trigger-npm-and-yarn-related-tasks-if-it-not-relevant-for-assemble
* We would like to explicitly disable this behaviour for kotlin standard library publication as it's shouldn't be needed but make the
* build slower, make it less stable, generated additional traffic, make the build less secure and so on.
*
* Implemented by manually removing dependencies set by Kotlin Gradle Plugin.
*/
fun Project.suppressYarnAndNpmForAssemble() {
afterEvaluate {
for (npmYarnTaskName in rootNpmRelatedTasks) {
tasks.findByPath(":$npmYarnTaskName") ?: error("Can't find root task $npmYarnTaskName")
}
val npmRelatedTasksNames = rootNpmRelatedTasks + ownNpmRelatedTasks
for (taskName in forbidImplicitDependOnNpmRelatedTasks) {
val task = project.tasks.findByName(taskName) ?: continue
if (!task.enabled) continue
val removeDependencies = task.dependsOn
.filterIsInstance(TaskProvider::class.java)
.filter { it.name in npmRelatedTasksNames }
.toSet()
if (removeDependencies.isNotEmpty()) {
task.setDependsOn(task.dependsOn - removeDependencies)
logger.info("Disable NPM/Yarn dependency tasks in $project - " +
"remove ${removeDependencies.joinToString(", ") { "'${it.name}'" }} dependencies from $task")
}
}
}
}
private fun findRootTasks(taskGraph: TaskExecutionGraph): List<Task> {
val allDependentTasksPaths = mutableSetOf<String>()
val allTasksPaths = mutableSetOf<String>()
@@ -4,8 +4,6 @@ plugins {
kotlin("multiplatform")
}
suppressYarnAndNpmForAssemble()
val commonMainSources by task<Sync> {
from(
"$rootDir/libraries/kotlin.test/common/src/main",
@@ -35,8 +35,6 @@ kotlin {
}
}
suppressYarnAndNpmForAssemble()
tasks.withType<KotlinCompile<*>>().configureEach {
kotlinOptions.freeCompilerArgs += listOf(
"-Xallow-kotlin-package",
@@ -10,8 +10,6 @@ kotlin {
}
}
suppressYarnAndNpmForAssemble()
val commonMainSources by task<Sync> {
dependsOn(":kotlin-stdlib-js-ir:commonMainSources")
from {
-2
View File
@@ -16,8 +16,6 @@ kotlin {
}
}
suppressYarnAndNpmForAssemble()
val unimplementedNativeBuiltIns =
(file("$rootDir/core/builtins/native/kotlin/").list().toSortedSet() - file("$rootDir/libraries/stdlib/js-ir/builtins/").list())
.map { "core/builtins/native/kotlin/$it" }
-2
View File
@@ -7,8 +7,6 @@ plugins {
kotlin("multiplatform")
}
suppressYarnAndNpmForAssemble()
description = "Kotlin Standard Library for experimental WebAssembly platform"
val unimplementedNativeBuiltIns =
@@ -28,8 +28,6 @@ kotlin {
}
}
suppressYarnAndNpmForAssemble()
configureCommonPublicationSettingsForGradle(signLibraryPublication)
publishing {