From 496ac4ccb6faa58237145796517366ecd4c660c5 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Tue, 12 Nov 2024 13:26:49 +0100 Subject: [PATCH] [Wasm] EnvSpec has executable provider and env instead of produceEnv --- js/js.tests/build.gradle.kts | 3 +-- js/js.tests/klib-compatibility/build.gradle.kts | 3 +-- .../api/all/kotlin-gradle-plugin.api | 15 ++++++++++----- .../kotlin/gradle/targets/js/AbstractEnvSpec.kt | 15 +++++++++++++-- .../kotlin/gradle/targets/js/AbstractSetupTask.kt | 2 +- .../targets/js/binaryen/BinaryenRootEnvSpec.kt | 10 +++++++--- .../targets/js/binaryen/BinaryenRootExtension.kt | 2 +- .../kotlin/gradle/targets/js/d8/D8EnvSpec.kt | 11 ++++++++--- .../kotlin/gradle/targets/js/d8/D8Exec.kt | 2 +- .../kotlin/gradle/targets/js/d8/D8Plugin.kt | 2 +- .../gradle/targets/js/d8/D8RootExtension.kt | 2 +- .../gradle/targets/js/nodejs/NodeJsEnvSpec.kt | 9 ++++++--- .../kotlin/gradle/targets/js/nodejs/NodeJsExec.kt | 2 +- .../targets/js/nodejs/NodeJsRootExtension.kt | 2 +- .../gradle/targets/js/nodejs/NodeJsRootPlugin.kt | 4 ++-- .../kotlin/gradle/targets/js/npm/NpmProject.kt | 2 +- .../targets/js/npm/tasks/KotlinNpmInstallTask.kt | 2 +- .../targets/js/npm/tasks/RootPackageJsonTask.kt | 2 +- .../gradle/targets/js/testing/KotlinJsTest.kt | 2 +- .../gradle/targets/js/testing/KotlinWasmD8.kt | 2 +- .../gradle/targets/js/testing/KotlinWasmNode.kt | 2 +- .../targets/js/testing/karma/KotlinKarma.kt | 2 +- .../targets/js/testing/mocha/KotlinMocha.kt | 2 +- .../kotlin/gradle/targets/js/yarn/YarnPlugin.kt | 2 +- .../gradle/targets/js/yarn/YarnRootEnvSpec.kt | 11 ++++++++--- .../gradle/targets/js/yarn/YarnRootExtension.kt | 2 +- wasm/wasm.tests/build.gradle.kts | 9 +++------ 27 files changed, 76 insertions(+), 48 deletions(-) diff --git a/js/js.tests/build.gradle.kts b/js/js.tests/build.gradle.kts index 6a6ac8e6e24e2..322d948ff1777 100644 --- a/js/js.tests/build.gradle.kts +++ b/js/js.tests/build.gradle.kts @@ -1,7 +1,6 @@ import com.github.gradle.node.npm.task.NpmTask import com.github.gradle.node.variant.computeNodeExec import org.apache.tools.ant.filters.FixCrLfFilter -import org.jetbrains.kotlin.build.d8.D8Extension import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute @@ -214,7 +213,7 @@ fun Test.setupNodeJs() { } fun Test.setUpJsBoxTests(tags: String?) { - with(project.the()) { + with(d8KotlinBuild) { setupV8() } diff --git a/js/js.tests/klib-compatibility/build.gradle.kts b/js/js.tests/klib-compatibility/build.gradle.kts index fbdb789c95b88..54d8a3d69639f 100644 --- a/js/js.tests/klib-compatibility/build.gradle.kts +++ b/js/js.tests/klib-compatibility/build.gradle.kts @@ -1,4 +1,3 @@ -import org.jetbrains.kotlin.build.d8.D8Extension import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute plugins { @@ -48,7 +47,7 @@ sourceSets { testsJar {} fun Test.setUpJsBoxTests() { - with(project.the()) { + with(d8KotlinBuild) { setupV8() } dependsOn(":dist") diff --git a/libraries/tools/kotlin-gradle-plugin/api/all/kotlin-gradle-plugin.api b/libraries/tools/kotlin-gradle-plugin/api/all/kotlin-gradle-plugin.api index a56757022da22..73d4a77f72fb5 100644 --- a/libraries/tools/kotlin-gradle-plugin/api/all/kotlin-gradle-plugin.api +++ b/libraries/tools/kotlin-gradle-plugin/api/all/kotlin-gradle-plugin.api @@ -3027,9 +3027,10 @@ public abstract class org/jetbrains/kotlin/gradle/targets/js/EnvSpec { public abstract fun getCommand ()Lorg/gradle/api/provider/Property; public abstract fun getDownload ()Lorg/gradle/api/provider/Property; public abstract fun getDownloadBaseUrl ()Lorg/gradle/api/provider/Property; + public abstract fun getExecutable ()Lorg/gradle/api/provider/Provider; public abstract fun getInstallationDirectory ()Lorg/gradle/api/file/DirectoryProperty; public abstract fun getVersion ()Lorg/gradle/api/provider/Property; - public abstract fun produceEnv (Lorg/gradle/api/provider/ProviderFactory;)Lorg/gradle/api/provider/Provider; + protected abstract fun produceEnv ()Lorg/gradle/api/provider/Provider; } public final class org/jetbrains/kotlin/gradle/targets/js/JsAggregatingExecutionSource : org/jetbrains/kotlin/gradle/execution/KotlinAggregateExecutionSource { @@ -3243,7 +3244,8 @@ public abstract class org/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenRo public static final field Companion Lorg/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenRootEnvSpec$Companion; public static final field EXTENSION_NAME Ljava/lang/String; public fun ()V - public fun produceEnv (Lorg/gradle/api/provider/ProviderFactory;)Lorg/gradle/api/provider/Provider; + public fun getExecutable ()Lorg/gradle/api/provider/Provider; + protected final fun produceEnv ()Lorg/gradle/api/provider/Provider; } public final class org/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenRootEnvSpec$Companion { @@ -3317,8 +3319,9 @@ public abstract class org/jetbrains/kotlin/gradle/targets/js/d8/D8EnvSpec : org/ public fun ()V public final fun getD8SetupTaskProvider (Lorg/gradle/api/Project;)Lorg/gradle/api/tasks/TaskProvider; public abstract fun getEdition ()Lorg/gradle/api/provider/Property; + public fun getExecutable ()Lorg/gradle/api/provider/Provider; public abstract fun getVersion ()Lorg/gradle/api/provider/Property; - public fun produceEnv (Lorg/gradle/api/provider/ProviderFactory;)Lorg/gradle/api/provider/Provider; + protected final fun produceEnv ()Lorg/gradle/api/provider/Provider; } public final class org/jetbrains/kotlin/gradle/targets/js/d8/D8EnvSpec$Companion { @@ -4121,8 +4124,9 @@ public abstract class org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsEnvSpe public static final field Companion Lorg/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsEnvSpec$Companion; public static final field EXTENSION_NAME Ljava/lang/String; public fun ()V + public fun getExecutable ()Lorg/gradle/api/provider/Provider; public final fun getNodeJsSetupTaskProvider (Lorg/gradle/api/Project;)Lorg/gradle/api/tasks/TaskProvider; - public fun produceEnv (Lorg/gradle/api/provider/ProviderFactory;)Lorg/gradle/api/provider/Provider; + protected final fun produceEnv ()Lorg/gradle/api/provider/Provider; } public final class org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsEnvSpec$Companion { @@ -5859,12 +5863,13 @@ public abstract class org/jetbrains/kotlin/gradle/targets/js/yarn/YarnRootEnvSpe public static final field Companion Lorg/jetbrains/kotlin/gradle/targets/js/yarn/YarnRootEnvSpec$Companion; public static final field YARN Ljava/lang/String; public fun ()V + public fun getExecutable ()Lorg/gradle/api/provider/Provider; public abstract fun getIgnoreScripts ()Lorg/gradle/api/provider/Property; public abstract fun getReportNewYarnLock ()Lorg/gradle/api/provider/Property; public abstract fun getResolutions ()Lorg/gradle/api/provider/ListProperty; public abstract fun getYarnLockAutoReplace ()Lorg/gradle/api/provider/Property; public abstract fun getYarnLockMismatchReport ()Lorg/gradle/api/provider/Property; - public fun produceEnv (Lorg/gradle/api/provider/ProviderFactory;)Lorg/gradle/api/provider/Provider; + protected final fun produceEnv ()Lorg/gradle/api/provider/Provider; } public final class org/jetbrains/kotlin/gradle/targets/js/yarn/YarnRootEnvSpec$Companion { diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/AbstractEnvSpec.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/AbstractEnvSpec.kt index b5d186355cc3b..cb8f55a3d18ae 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/AbstractEnvSpec.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/AbstractEnvSpec.kt @@ -4,13 +4,14 @@ import org.gradle.api.file.DirectoryProperty import org.gradle.api.provider.Property import org.gradle.api.provider.Provider import org.gradle.api.provider.ProviderFactory +import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnEnv /** * Instance which describes specific runtimes for JS and Wasm targets * * It encapsulates necessary information about a tool to run application and tests */ -abstract class EnvSpec { +abstract class EnvSpec { /** * Specify whether we need to download the tool @@ -40,8 +41,18 @@ abstract class EnvSpec { */ abstract val command: Property + /** + * Full serializable cache-friendly entity without Gradle Provider API + */ + internal abstract val env: Provider + + /** + * Provider with full executable path + */ + abstract val executable: Provider + /** * Produce full serializable cache-friendly entity without Gradle Provider API */ - abstract fun produceEnv(providerFactory: ProviderFactory): Provider + protected abstract fun produceEnv(): Provider } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/AbstractSetupTask.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/AbstractSetupTask.kt index d01f086068c86..1545c4a65f48e 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/AbstractSetupTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/AbstractSetupTask.kt @@ -34,7 +34,7 @@ abstract class AbstractSetupTask>( protected abstract val artifactName: String @get:Internal - protected val env: Provider = spec.produceEnv(project.providers) + protected val env: Provider = spec.env private val shouldDownload: Provider = env.map { it.download } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenRootEnvSpec.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenRootEnvSpec.kt index 8125c198b1e74..3966a2dd60178 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenRootEnvSpec.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenRootEnvSpec.kt @@ -10,6 +10,7 @@ import org.gradle.api.provider.Provider import org.gradle.api.provider.ProviderFactory import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl import org.jetbrains.kotlin.gradle.targets.js.EnvSpec +import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsEnv import org.jetbrains.kotlin.gradle.tasks.internal.CleanableStore import org.jetbrains.kotlin.gradle.utils.getFile @@ -24,9 +25,12 @@ abstract class BinaryenRootEnvSpec : EnvSpec() { */ internal abstract val platform: Property - override fun produceEnv(providerFactory: ProviderFactory): Provider { - return providerFactory.provider { - val versionValue = version.get() + final override val env: Provider = produceEnv() + + override val executable: Provider = env.map { it.executable } + + final override fun produceEnv(): Provider { + return version.map { versionValue -> val requiredVersionName = "binaryen-version_$versionValue" val cleanableStore = CleanableStore[installationDirectory.getFile().absolutePath] val targetPath = cleanableStore[requiredVersionName].use() diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenRootExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenRootExtension.kt index b228cdd14eeb3..5006c1240871a 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenRootExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenRootExtension.kt @@ -48,7 +48,7 @@ open class BinaryenRootExtension( internal val platform: org.gradle.api.provider.Property = rootProject.objects.property() override fun finalizeConfiguration(): BinaryenEnv { - return binaryenSpec.produceEnv(rootProject.providers).get() + return binaryenSpec.env.get() } companion object { diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8EnvSpec.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8EnvSpec.kt index 3109a3c86e592..604e92e46685d 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8EnvSpec.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8EnvSpec.kt @@ -11,6 +11,7 @@ import org.gradle.api.provider.ProviderFactory import org.gradle.api.tasks.TaskProvider import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl import org.jetbrains.kotlin.gradle.targets.js.EnvSpec +import org.jetbrains.kotlin.gradle.targets.js.binaryen.BinaryenEnv import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsSetupTask import org.jetbrains.kotlin.gradle.tasks.internal.CleanableStore import org.jetbrains.kotlin.gradle.utils.getFile @@ -45,9 +46,13 @@ abstract class D8EnvSpec : EnvSpec() { */ abstract val edition: org.gradle.api.provider.Property - override fun produceEnv(providerFactory: ProviderFactory): Provider { - return providerFactory.provider { - val requiredVersion = "${D8Platform.platform}-${edition.get()}-${version.get()}" + final override val env: Provider = produceEnv() + + override val executable: Provider = env.map { it.executable } + + final override fun produceEnv(): Provider { + return edition.map { editionValue -> + val requiredVersion = "${D8Platform.platform}-$editionValue-${version.get()}" val requiredVersionName = "v8-$requiredVersion" val cleanableStore = CleanableStore[installationDirectory.getFile().absolutePath] val targetPath = cleanableStore[requiredVersionName].use() diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8Exec.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8Exec.kt index 48ca2fbf5e682..3389ceeb37517 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8Exec.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8Exec.kt @@ -63,7 +63,7 @@ open class D8Exec : AbstractExecTask(D8Exec::class.java) { return project.registerTask( name ) { - it.executable = d8.produceEnv(project.providers).get().executable + it.executable = d8.executable.get() with(d8) { it.dependsOn(project.d8SetupTaskProvider) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8Plugin.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8Plugin.kt index 036d885f56367..c17d25065fa61 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8Plugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8Plugin.kt @@ -49,7 +49,7 @@ open class D8Plugin : Plugin { } project.registerTask("d8" + CleanDataTask.NAME_SUFFIX) { - it.cleanableStoreProvider = spec.produceEnv(project.providers).map { it.cleanableStore } + it.cleanableStoreProvider = spec.env.map { it.cleanableStore } it.group = TASKS_GROUP_NAME it.description = "Clean unused local d8 version" } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8RootExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8RootExtension.kt index 8659f5b398547..1268c1295a68c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8RootExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8RootExtension.kt @@ -51,7 +51,7 @@ open class D8RootExtension( .convention("d8") override fun finalizeConfiguration(): D8Env { - return d8EnvSpec.produceEnv(project.providers).get() + return d8EnvSpec.env.get() } val setupTaskProvider: TaskProvider diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsEnvSpec.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsEnvSpec.kt index d14e2bde6406b..6a5eb767f4fa6 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsEnvSpec.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsEnvSpec.kt @@ -24,9 +24,12 @@ abstract class NodeJsEnvSpec : EnvSpec() { */ internal abstract val platform: org.gradle.api.provider.Property - override fun produceEnv(providerFactory: ProviderFactory): Provider { - return providerFactory.provider { - val platformValue = platform.get() + final override val env: Provider = produceEnv() + + override val executable: Provider = env.map { it.executable } + + final override fun produceEnv(): Provider { + return platform.map { platformValue -> val name = platformValue.name val architecture = platformValue.arch diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsExec.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsExec.kt index 4d3077c49d446..d212646f6bb67 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsExec.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsExec.kt @@ -106,7 +106,7 @@ constructor( listOf(compilation) ) { it.nodeJsRoot = nodeJsRoot - it.executable = nodeJs.produceEnv(project.providers).get().executable + it.executable = nodeJs.executable.get() if ((compilation.target as? KotlinJsIrTarget)?.wasmTargetType != KotlinWasmTargetType.WASI) { it.workingDir(npmProject.dir) it.dependsOn( diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt index 07d72729b224e..e99b07691a57c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt @@ -143,7 +143,7 @@ open class NodeJsRootExtension( @Deprecated("Use NodeJsEnvSpec instead. This will be removed in 2.2") fun requireConfigured(): NodeJsEnv { - return nodeJs().produceEnv(project.providers).get() + return nodeJs().env.get() } companion object { diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootPlugin.kt index 0f48a344d78e5..726078c40a74d 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootPlugin.kt @@ -57,7 +57,7 @@ open class NodeJsRootPlugin : Plugin { val nodeJs = NodeJsPlugin.apply(project) npm.nodeJsEnvironment.value( - nodeJs.produceEnv(project.providers) + nodeJs.env ).disallowChanges() nodeJsRoot.packageManagerExtension.convention( @@ -234,7 +234,7 @@ open class NodeJsRootPlugin : Plugin { } project.tasks.register("node" + CleanDataTask.NAME_SUFFIX, CleanDataTask::class.java) { - it.cleanableStoreProvider = nodeJs.produceEnv(project.providers).map { it.cleanableStore } + it.cleanableStoreProvider = nodeJs.env.map { it.cleanableStore } it.group = TASKS_GROUP_NAME it.description = "Clean unused local node version" } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt index 6a0e44ddbd48a..4694657e766fd 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt @@ -94,7 +94,7 @@ open class NpmProject(@Transient val compilation: KotlinJsIrCompilation) : Seria } private val nodeExecutable by lazy { - nodeJs.produceEnv(project.providers).get().executable + nodeJs.executable.get() } fun useTool( diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinNpmInstallTask.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinNpmInstallTask.kt index 4a4aec62f746c..77a10f0e27cd2 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinNpmInstallTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinNpmInstallTask.kt @@ -48,7 +48,7 @@ abstract class KotlinNpmInstallTask : // ----- private val nodsJsEnvironment by lazy { - asNodeJsEnvironment(nodeJsRoot, nodeJs.produceEnv(project.providers).get()) + asNodeJsEnvironment(nodeJsRoot, nodeJs.env.get()) } private val packageManagerEnv by lazy { diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/RootPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/RootPackageJsonTask.kt index 5ad6b4ee1a509..f8c8242ca355c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/RootPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/RootPackageJsonTask.kt @@ -47,7 +47,7 @@ abstract class RootPackageJsonTask : // ----- private val nodeJsEnvironment by lazy { - asNodeJsEnvironment(nodeJsRoot, nodeJs.produceEnv(project.providers).get()) + asNodeJsEnvironment(nodeJsRoot, nodeJs.env.get()) } private val packageManagerEnv by lazy { diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt index 4bd391c5d2bf5..7a6f61e8ed2b2 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt @@ -37,7 +37,7 @@ constructor( @Transient private val nodeJs = project.kotlinNodeJsEnvSpec - private val nodeExecutable = nodeJs.produceEnv(project.providers).map { it.executable } + private val nodeExecutable = nodeJs.executable @Input var environment = mutableMapOf() diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinWasmD8.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinWasmD8.kt index 7140320996945..c40c24d8c8389 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinWasmD8.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinWasmD8.kt @@ -31,7 +31,7 @@ internal class KotlinWasmD8(kotlinJsTest: KotlinJsTest) : KotlinJsTestFramework override val workingDir: Provider = projectLayout.dir(kotlinJsTest.inputFileProperty.asFile.map { it.parentFile }) - override val executable: Provider = d8.produceEnv(compilation.project.providers).map { it.executable } + override val executable: Provider = d8.executable override fun createTestExecutionSpec( task: KotlinJsTest, diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinWasmNode.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinWasmNode.kt index b0a3cbe1b4f05..dd2450a1aee08 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinWasmNode.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinWasmNode.kt @@ -42,7 +42,7 @@ internal class KotlinWasmNode(kotlinJsTest: KotlinJsTest) : KotlinJsTestFramewor } } - override val executable: Provider = nodeJs.produceEnv(kotlinJsTest.project.providers).map { it.executable } + override val executable: Provider = nodeJs.executable override fun createTestExecutionSpec( task: KotlinJsTest, diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt index 083517b045beb..b7fe4bf190fed 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt @@ -81,7 +81,7 @@ class KotlinKarma( override val workingDir: Provider get() = npmProjectDir - override val executable: Provider = nodeJsEnvSpec.produceEnv(project.providers).map { it.executable } + override val executable: Provider = nodeJsEnvSpec.executable override fun getPath() = "$basePath:kotlinKarma" diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt index 11db434b3fe8e..0b14258eb86d6 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt @@ -38,7 +38,7 @@ class KotlinMocha(@Transient override val compilation: KotlinJsIrCompilation, pr override val workingDir: Provider get() = npmProjectDir - override val executable: Provider = nodeJs.produceEnv(project.providers).map { it.executable } + override val executable: Provider = nodeJs.executable override val settingsState: String get() = "mocha" diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnPlugin.kt index 0d4d706a78a0f..5fc0ce0455230 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnPlugin.kt @@ -73,7 +73,7 @@ open class YarnPlugin : Plugin { } yarnRootExtension.nodeJsEnvironment.value( - nodeJs.produceEnv(project.providers) + nodeJs.env ).disallowChanges() tasks.register("yarn" + CleanDataTask.NAME_SUFFIX, CleanDataTask::class.java) { diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnRootEnvSpec.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnRootEnvSpec.kt index 5deb5b2f52ee1..6ba88eb96d355 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnRootEnvSpec.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnRootEnvSpec.kt @@ -10,6 +10,7 @@ import org.gradle.api.provider.Property import org.gradle.api.provider.Provider import org.gradle.api.provider.ProviderFactory import org.jetbrains.kotlin.gradle.targets.js.EnvSpec +import org.jetbrains.kotlin.gradle.targets.js.binaryen.BinaryenEnv import org.jetbrains.kotlin.gradle.targets.js.nodejs.Platform import org.jetbrains.kotlin.gradle.tasks.internal.CleanableStore import org.jetbrains.kotlin.gradle.utils.getFile @@ -60,11 +61,15 @@ abstract class YarnRootEnvSpec : EnvSpec() { */ abstract val resolutions: ListProperty - override fun produceEnv(providerFactory: ProviderFactory): Provider { - return providerFactory.provider { + final override val env: Provider = produceEnv() + + override val executable: Provider = env.map { it.executable } + + final override fun produceEnv(): Provider { + return platform.map { platformValue -> val cleanableStore = CleanableStore[installationDirectory.getFile().path] - val isWindows = platform.get().isWindows() + val isWindows = platformValue.isWindows() val home = cleanableStore["yarn-v${version.get()}"].use() diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnRootExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnRootExtension.kt index f3bf54eb66940..041508b4f0d99 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnRootExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnRootExtension.kt @@ -102,7 +102,7 @@ open class YarnRootExtension( internal val nodeJsEnvironment: org.gradle.api.provider.Property = project.objects.property(NodeJsEnv::class.java) override fun finalizeConfiguration(): YarnEnv { - return yarnSpec.produceEnv(project.providers).get() + return yarnSpec.env.get() } val restoreYarnLockTaskProvider: TaskProvider diff --git a/wasm/wasm.tests/build.gradle.kts b/wasm/wasm.tests/build.gradle.kts index 4b60c82d7146b..8c7f608e73df8 100644 --- a/wasm/wasm.tests/build.gradle.kts +++ b/wasm/wasm.tests/build.gradle.kts @@ -1,9 +1,6 @@ import org.gradle.internal.os.OperatingSystem import java.net.URI import com.github.gradle.node.npm.task.NpmTask -import org.jetbrains.kotlin.build.binaryen.BinaryenExtension -import org.jetbrains.kotlin.build.d8.D8Extension -import org.jetbrains.kotlin.build.nodejs.NodeJsExtension import java.nio.file.Files import java.util.* @@ -281,13 +278,13 @@ fun Project.wasmProjectTest( jUnitMode = JUnitMode.JUnit5 ) { workingDir = rootDir - with(project.the()) { + with(d8KotlinBuild) { setupV8() } - with(project.the()) { + with(nodeJsKotlinBuild) { setupNodeJs() } - with(project.the()) { + with(binaryenKotlinBuild) { setupBinaryen() } setupSpiderMonkey()