From ab6bdbb1be873d93ca13956dff502e739fe62796 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Tue, 19 Nov 2024 13:38:13 +0000 Subject: [PATCH] [Wasm] Init downloadBaseUrl with set instead of convention ^KT-72872 fixed ^KT-72874 fixed --- .../kotlin/gradle/NodeJsGradlePluginIT.kt | 14 +++++++++++++ .../build.gradle.kts | 13 ++++++++++++ .../settings.gradle.kts | 21 +++++++++++++++++++ .../gradle/targets/js/nodejs/NodeJsPlugin.kt | 3 ++- .../targets/js/nodejs/NodeJsRootExtension.kt | 20 +++++++++--------- 5 files changed, 60 insertions(+), 11 deletions(-) create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/nodejs-setup-with-user-repositories/build.gradle.kts create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/nodejs-setup-with-user-repositories/settings.gradle.kts diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NodeJsGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NodeJsGradlePluginIT.kt index 3a2134995dac2..1c3af34ebad2f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NodeJsGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NodeJsGradlePluginIT.kt @@ -86,4 +86,18 @@ class NodeJsGradlePluginIT : KGPBaseTest() { } } } + + @DisplayName("Node.js setup test with downloadBaseUrl = null") + @GradleTest + @TestMetadata("subprojects-nodejs-setup") + fun testSetupWithoutDownloadBaseUrl(gradleVersion: GradleVersion) { + project( + "nodejs-setup-with-user-repositories", + gradleVersion, + // we can remove this line, when the min version of Gradle be at least 8.1 + dependencyManagement = DependencyManagement.DisabledDependencyManagement + ) { + build(":kotlinNodeJsSetup") + } + } } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/nodejs-setup-with-user-repositories/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/nodejs-setup-with-user-repositories/build.gradle.kts new file mode 100644 index 0000000000000..6feaa2a2138bf --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/nodejs-setup-with-user-repositories/build.gradle.kts @@ -0,0 +1,13 @@ +plugins { + id("org.jetbrains.kotlin.multiplatform") +} + +kotlin { + js { + nodejs() + } +} + +plugins.withType { + the().downloadBaseUrl.set(null as String?) +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/nodejs-setup-with-user-repositories/settings.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/nodejs-setup-with-user-repositories/settings.gradle.kts new file mode 100644 index 0000000000000..8bc353d309c80 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/nodejs-setup-with-user-repositories/settings.gradle.kts @@ -0,0 +1,21 @@ +import org.gradle.api.artifacts.repositories.IvyArtifactRepository +import java.net.URI + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + mavenLocal() + mavenCentral() + + ivy { + name = "Distributions at https://nodejs.org/dist" + url = URI("https://nodejs.org/dist") + + patternLayout { + artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]") + } + metadataSources { artifact() } + content { includeModule("org.nodejs", "node") } + } + } +} diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsPlugin.kt index 43349bd84fe75..3b7b7675d9102 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsPlugin.kt @@ -50,7 +50,8 @@ open class NodeJsPlugin : Plugin { ) ) download.convention(objects.providerWithLazyConvention { nodeJsConstructor().download }) - downloadBaseUrl.convention(objects.providerWithLazyConvention { nodeJsConstructor().downloadBaseUrl }) + // set instead of convention because it is possible to have null value + downloadBaseUrl.set(objects.providerWithLazyConvention { nodeJsConstructor().downloadBaseUrl }) version.convention(objects.providerWithLazyConvention { nodeJsConstructor().version }) command.convention(objects.providerWithLazyConvention { nodeJsConstructor().command }) 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 3f4ef4f0d4d7f..07d72729b224e 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 @@ -50,52 +50,52 @@ open class NodeJsRootExtension( } @Deprecated( - "Use installationDir from NodeJsExtension (not NodeJsRootExtension) instead." + + "Use installationDir from NodeJsEnvSpec (not NodeJsRootExtension) instead." + "You can find this extension after applying NodeJsPlugin. This will be removed in 2.2" ) var installationDir: File = gradleHome.resolve("nodejs") @Deprecated( - "Use download from NodeJsExtension (not NodeJsRootExtension) instead" + + "Use download from NodeJsEnvSpec (not NodeJsRootExtension) instead" + "You can find this extension after applying NodeJsPlugin. This will be removed in 2.2" ) var download = true @Suppress("DEPRECATION") @Deprecated( - "Use downloadBaseUrl from NodeJsExtension (not NodeJsRootExtension) instead" + + "Use downloadBaseUrl from NodeJsEnvSpec (not NodeJsRootExtension) instead" + "You can find this extension after applying NodeJsPlugin. This will be removed in 2.2" ) var nodeDownloadBaseUrl by ::downloadBaseUrl @Deprecated( - "Use downloadBaseUrl from NodeJsExtension (not NodeJsRootExtension) instead" + + "Use downloadBaseUrl from NodeJsEnvSpec (not NodeJsRootExtension) instead" + "You can find this extension after applying NodeJsPlugin. This will be removed in 2.2" ) var downloadBaseUrl: String? = "https://nodejs.org/dist" @Suppress("DEPRECATION") @Deprecated( - "Use version from NodeJsExtension (not NodeJsRootExtension) instead" + + "Use version from NodeJsEnvSpec (not NodeJsRootExtension) instead" + "You can find this extension after applying NodeJsPlugin. This will be removed in 2.2" ) var nodeVersion by ::version @Deprecated( - "Use downloadBaseUrl from NodeJsExtension (not NodeJsRootExtension) instead" + + "Use downloadBaseUrl from NodeJsEnvSpec (not NodeJsRootExtension) instead" + "You can find this extension after applying NodeJsPlugin. This will be removed in 2.2" ) var version = "22.0.0" @Deprecated( - "Use command from NodeJsExtension (not NodeJsRootExtension) instead" + + "Use command from NodeJsEnvSpec (not NodeJsRootExtension) instead" + "You can find this extension after applying NodeJsPlugin. This will be removed in 2.2" ) var command = "node" @Suppress("DEPRECATION") @Deprecated( - "Use command from NodeJsExtension (not NodeJsRootExtension) instead" + + "Use command from NodeJsEnvSpec (not NodeJsRootExtension) instead" + "You can find this extension after applying NodeJsPlugin. This will be removed in 2.2" ) var nodeCommand by ::command @@ -133,7 +133,7 @@ open class NodeJsRootExtension( get() = project.tasks.withType(KotlinNpmCachesSetup::class.java).named(KotlinNpmCachesSetup.NAME) @Deprecated( - "Use nodeJsSetupTaskProvider from NodeJsExtension (not NodeJsRootExtension) instead" + + "Use nodeJsSetupTaskProvider from NodeJsEnvSpec (not NodeJsRootExtension) instead" + "You can find this extension after applying NodeJsPlugin" ) val nodeJsSetupTaskProvider: TaskProvider @@ -141,7 +141,7 @@ open class NodeJsRootExtension( project.nodeJsSetupTaskProvider } - @Deprecated("Use NodeJsExtension instead. This will be removed in 2.2") + @Deprecated("Use NodeJsEnvSpec instead. This will be removed in 2.2") fun requireConfigured(): NodeJsEnv { return nodeJs().produceEnv(project.providers).get() }