diff --git a/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/setupV8.kt b/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/setupV8.kt deleted file mode 100644 index af295f4ce3c92..0000000000000 --- a/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/setupV8.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ -@file:Suppress("DEPRECATION") - -import org.gradle.api.Project -import org.gradle.api.tasks.testing.Test -import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension -import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin - - -private object NodeJsUtils { - lateinit var nodeJsPlugin: NodeJsRootExtension - - fun useNodeJsPlugin(project: Project) { - nodeJsPlugin = NodeJsRootPlugin.apply(project.rootProject) - } -} - -fun Project.useNodeJsPlugin() { - NodeJsUtils.useNodeJsPlugin(this) -} - -@Suppress("DEPRECATION") -fun Test.setupNodeJs() { - dependsOn(NodeJsUtils.nodeJsPlugin.nodeJsSetupTaskProvider) - val nodeJsExecutablePath = project.provider { - NodeJsUtils.nodeJsPlugin.requireConfigured().nodeExecutable - } - doFirst { - systemProperty("javascript.engine.path.NodeJs", nodeJsExecutablePath.get()) - } -} - diff --git a/repo/gradle-build-conventions/nodejs-configuration/build.gradle.kts b/repo/gradle-build-conventions/nodejs-configuration/build.gradle.kts new file mode 100644 index 0000000000000..212ffe419ea83 --- /dev/null +++ b/repo/gradle-build-conventions/nodejs-configuration/build.gradle.kts @@ -0,0 +1,27 @@ +plugins { + `kotlin-dsl` + id("org.jetbrains.kotlin.jvm") +} + +repositories { + maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") + mavenCentral() + gradlePluginPortal() + + extra["bootstrapKotlinRepo"]?.let { + maven(url = it) + } +} + +kotlin { + jvmToolchain(8) + + compilerOptions { + allWarningsAsErrors.set(true) + } +} + +dependencies { + compileOnly(kotlin("stdlib", embeddedKotlinVersion)) + compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}") +} diff --git a/repo/gradle-build-conventions/nodejs-configuration/src/main/kotlin/nodejs-configuration.gradle.kts b/repo/gradle-build-conventions/nodejs-configuration/src/main/kotlin/nodejs-configuration.gradle.kts new file mode 100644 index 0000000000000..b03711bb95c28 --- /dev/null +++ b/repo/gradle-build-conventions/nodejs-configuration/src/main/kotlin/nodejs-configuration.gradle.kts @@ -0,0 +1,9 @@ +import org.jetbrains.kotlin.build.nodejs.NodeJsExtension +import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin + +val nodeJsRoot = NodeJsRootPlugin.apply(project.rootProject) + +extensions.create( + "nodeJsKotlinBuild", + nodeJsRoot, +) \ No newline at end of file diff --git a/repo/gradle-build-conventions/nodejs-configuration/src/main/kotlin/org/jetbrains/kotlin/build/nodejs/NodeJsExtension.kt b/repo/gradle-build-conventions/nodejs-configuration/src/main/kotlin/org/jetbrains/kotlin/build/nodejs/NodeJsExtension.kt new file mode 100644 index 0000000000000..fef760803d6fc --- /dev/null +++ b/repo/gradle-build-conventions/nodejs-configuration/src/main/kotlin/org/jetbrains/kotlin/build/nodejs/NodeJsExtension.kt @@ -0,0 +1,24 @@ +/* + * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.build.nodejs + +import org.gradle.api.tasks.testing.Test +import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension + +abstract class NodeJsExtension( + private val nodeJsRoot: NodeJsRootExtension +) { + @Suppress("DEPRECATION") + fun Test.setupNodeJs() { + dependsOn(nodeJsRoot.nodeJsSetupTaskProvider) + val nodeJsExecutablePath = project.provider { + nodeJsRoot.requireConfigured().nodeExecutable + } + doFirst { + systemProperty("javascript.engine.path.NodeJs", nodeJsExecutablePath.get()) + } + } +} \ No newline at end of file diff --git a/repo/gradle-build-conventions/settings.gradle.kts b/repo/gradle-build-conventions/settings.gradle.kts index 50733c87f9fdd..2a3941554abd4 100644 --- a/repo/gradle-build-conventions/settings.gradle.kts +++ b/repo/gradle-build-conventions/settings.gradle.kts @@ -36,4 +36,5 @@ include(":binary-compatibility-extended") include(":gradle-plugins-documentation") include(":gradle-plugins-common") include(":d8-configuration") -include(":binaryen-configuration") \ No newline at end of file +include(":binaryen-configuration") +include(":nodejs-configuration") \ No newline at end of file diff --git a/wasm/wasm.tests/build.gradle.kts b/wasm/wasm.tests/build.gradle.kts index e7f8779ab4b2f..4b60c82d7146b 100644 --- a/wasm/wasm.tests/build.gradle.kts +++ b/wasm/wasm.tests/build.gradle.kts @@ -3,6 +3,7 @@ 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.* @@ -12,6 +13,7 @@ plugins { alias(libs.plugins.gradle.node) id("d8-configuration") id("binaryen-configuration") + id("nodejs-configuration") } node { @@ -126,7 +128,6 @@ dependencies { val generationRoot = projectDir.resolve("tests-gen") -useNodeJsPlugin() optInToExperimentalCompilerApi() sourceSets { @@ -283,7 +284,9 @@ fun Project.wasmProjectTest( with(project.the()) { setupV8() } - setupNodeJs() + with(project.the()) { + setupNodeJs() + } with(project.the()) { setupBinaryen() }