From 2d28a115710dfef2c404ba924770f06f9de0bce0 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Wed, 16 Oct 2024 11:55:21 +0000 Subject: [PATCH] [Wasm] Deprecate JS infrastructure declarations --- build.gradle.kts | 2 ++ libraries/stdlib/build.gradle.kts | 5 +++-- .../kotlin/gradle/NodeJsGradlePluginIT.kt | 1 + .../new-mpp-wasm-test/build.gradle.kts | 13 ++++++------ .../new-mpp-wasm-wasi-test/build.gradle.kts | 13 ++++++------ .../api/all/kotlin-gradle-plugin.api | 1 - .../gradle/targets/js/AbstractSettings.kt | 6 ++---- .../kotlin/gradle/targets/js/d8/D8Plugin.kt | 3 +-- .../gradle/targets/js/d8/D8RootPlugin.kt | 3 +-- .../targets/js/nodejs/NodeJsRootExtension.kt | 20 +++++++++---------- .../kotlin/resolve-dependencies.gradle.kts | 2 ++ .../src/main/kotlin/setupV8.kt | 7 ++++++- 12 files changed, 42 insertions(+), 34 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index e2edd665bcad7..1ba4ef303f0ab 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1148,6 +1148,7 @@ if (disableVerificationTasks) { gradle.taskGraph.whenReady(checkYarnAndNPMSuppressed) +@Suppress("DEPRECATION") plugins.withType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin::class) { extensions.configure(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension::class.java) { if (kotlinBuildProperties.isCacheRedirectorEnabled) { @@ -1168,6 +1169,7 @@ plugins.withType(com.github.gradle.node.NodePlugin::class) { } } +@Suppress("DEPRECATION") afterEvaluate { if (kotlinBuildProperties.isCacheRedirectorEnabled) { rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin::class.java) { diff --git a/libraries/stdlib/build.gradle.kts b/libraries/stdlib/build.gradle.kts index 4424ff9d7c26b..318586e092518 100644 --- a/libraries/stdlib/build.gradle.kts +++ b/libraries/stdlib/build.gradle.kts @@ -1,4 +1,4 @@ -@file:Suppress("UNUSED_VARIABLE", "NAME_SHADOWING") +@file:Suppress("UNUSED_VARIABLE", "NAME_SHADOWING", "DEPRECATION") import org.gradle.jvm.tasks.Jar import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions @@ -254,7 +254,8 @@ kotlin { } } - D8RootPlugin.apply(rootProject).version = v8Version + rootProject.plugins.apply(D8RootPlugin::class.java) + rootProject.the().version = v8Version fun KotlinWasmTargetDsl.commonWasmTargetConfiguration() { (this as KotlinTargetWithNodeJsDsl).nodejs() 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 1c93434d4df80..3a2134995dac2 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 @@ -70,6 +70,7 @@ class NodeJsGradlePluginIT : KGPBaseTest() { "subprojects-nodejs-setup", gradleVersion ) { + @Suppress("DEPRECATION") buildScriptInjection { project.rootProject.plugins.withType(NodeJsRootPlugin::class.java, Action { project.rootProject.extensions.getByType(NodeJsRootExtension::class.java).version = "22.3.0" diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-wasm-test/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-wasm-test/build.gradle.kts index b34ee25ea12b1..0e6a2d322a9a2 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-wasm-test/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-wasm-test/build.gradle.kts @@ -7,12 +7,6 @@ repositories { mavenCentral() } -with(org.jetbrains.kotlin.gradle.targets.js.d8.D8Plugin.apply(rootProject)) { - // Test that we can set the version and it is a String. - // But use the default version since update this place every time anyway. - version = (version as String) -} - kotlin { wasmJs { { @@ -33,6 +27,13 @@ kotlin { } } +rootProject.plugins.apply(org.jetbrains.kotlin.gradle.targets.js.d8.D8Plugin::class.java) +rootProject.the().apply { + // Test that we can set the version and it is a String. + // But use the default version since update this place every time anyway. + version = (version as String) +} + tasks.named("kotlinStorePackageLock") { //A little hacky way to make yarn results inputFile.fileValue(projectDir.resolve("packageLockStub")) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-wasm-wasi-test/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-wasm-wasi-test/build.gradle.kts index 0038899e41656..44fdafa24c35f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-wasm-wasi-test/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-wasm-wasi-test/build.gradle.kts @@ -2,12 +2,6 @@ plugins { kotlin("multiplatform") } -with(org.jetbrains.kotlin.gradle.targets.js.d8.D8Plugin.apply(rootProject)) { - // Test that we can set the version and it is a String. - // But use the default version since update this place every time anyway. - version = (version as String) -} - repositories { mavenLocal() mavenCentral() @@ -29,6 +23,13 @@ kotlin { } } +rootProject.plugins.apply(org.jetbrains.kotlin.gradle.targets.js.d8.D8Plugin::class.java) +rootProject.the().apply { + // Test that we can set the version and it is a String. + // But use the default version since update this place every time anyway. + version = (version as String) +} + tasks.named("kotlinStorePackageLock") { //A little hacky way to make yarn results inputFile.fileValue(projectDir.resolve("packageLockStub")) 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 8e94927eb1749..f59631ea4731c 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 @@ -3361,7 +3361,6 @@ public class org/jetbrains/kotlin/gradle/targets/js/d8/D8Plugin : org/gradle/api } public final class org/jetbrains/kotlin/gradle/targets/js/d8/D8Plugin$Companion { - public final fun apply (Lorg/gradle/api/Project;)Lorg/jetbrains/kotlin/gradle/targets/js/d8/D8RootExtension; } public class org/jetbrains/kotlin/gradle/targets/js/d8/D8RootExtension : org/jetbrains/kotlin/gradle/targets/js/AbstractSettings { diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/AbstractSettings.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/AbstractSettings.kt index 627b4f0de39d9..63026171aaff2 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/AbstractSettings.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/AbstractSettings.kt @@ -16,8 +16,7 @@ abstract class AbstractSettings : ConfigurationPhaseAware - // To prevent Kotlin build from failing (due to `-Werror`), only deprecate after upgrade of bootstrap version -// @Deprecated("This property has been migrated to support the Provider API. Use downloadBaseUrlProperty instead. This will be removed in version 2.2.") + @Deprecated("This property has been migrated to support the Provider API. Use downloadBaseUrlProperty instead. This will be removed in version 2.2.") var downloadBaseUrl: String? get() = downloadBaseUrlProperty.getOrNull() set(value) { @@ -35,8 +34,7 @@ abstract class AbstractSettings : ConfigurationPhaseAware { companion object { const val TASKS_GROUP_NAME: String = "d8" - // To prevent Kotlin build from failing (due to `-Werror`), only internalize after upgrade of bootstrap version -// @InternalKotlinGradlePluginApi + @InternalKotlinGradlePluginApi fun apply(project: Project): D8RootExtension { project.plugins.apply(D8Plugin::class.java) return project.extensions.getByName(EXTENSION_NAME) as D8RootExtension diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8RootPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8RootPlugin.kt index fd0097c057d3e..762f833ea8962 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8RootPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/d8/D8RootPlugin.kt @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.gradle.targets.js.d8 import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl // To be compatible with previous KGP version, we need to keep D8RootPlugin as deprecated. -// To prevent Kotlin build from failing (due to `-Werror`), only deprecate after upgrade of bootstrap version -//@Deprecated("This type is deprecated. Use D8Plugin instead.", ReplaceWith("D8Plugin")) +@Deprecated("This type is deprecated. Use D8Plugin instead.", ReplaceWith("D8Plugin")) @OptIn(ExperimentalWasmDsl::class) typealias D8RootPlugin = D8Plugin \ No newline at end of file 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 65857b7c96214..3f4ef4f0d4d7f 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 @@ -61,30 +61,30 @@ open class NodeJsRootExtension( ) var download = true + @Suppress("DEPRECATION") @Deprecated( "Use downloadBaseUrl from NodeJsExtension (not NodeJsRootExtension) instead" + "You can find this extension after applying NodeJsPlugin. This will be removed in 2.2" ) var nodeDownloadBaseUrl by ::downloadBaseUrl - // To prevent Kotlin build from failing (due to `-Werror`), only deprecate after upgrade of bootstrap version -// @Deprecated( -// "Use downloadBaseUrl from NodeJsExtension (not NodeJsRootExtension) instead" + -// "You can find this extension after applying NodeJsPlugin. This will be removed in 2.2" -// ) + @Deprecated( + "Use downloadBaseUrl from NodeJsExtension (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" + "You can find this extension after applying NodeJsPlugin. This will be removed in 2.2" ) var nodeVersion by ::version - // To prevent Kotlin build from failing (due to `-Werror`), only deprecate after upgrade of bootstrap version -// @Deprecated( -// "Use downloadBaseUrl from NodeJsExtension (not NodeJsRootExtension) instead" + -// "You can find this extension after applying NodeJsPlugin. This will be removed in 2.2" -// ) + @Deprecated( + "Use downloadBaseUrl from NodeJsExtension (not NodeJsRootExtension) instead" + + "You can find this extension after applying NodeJsPlugin. This will be removed in 2.2" + ) var version = "22.0.0" @Deprecated( diff --git a/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/resolve-dependencies.gradle.kts b/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/resolve-dependencies.gradle.kts index 9851457de79ce..2c0dab958c7f3 100644 --- a/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/resolve-dependencies.gradle.kts +++ b/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/resolve-dependencies.gradle.kts @@ -42,6 +42,8 @@ val resolveJsTools by tasks.registering { description = "Resolves JavaScript tools (for dependency verification or populating caches)." notCompatibleWithConfigurationCache("Uses project during task execution") doNotTrackState("The task must always re-run to ensure that all dependencies are downloaded.") + + @Suppress("DEPRECATION") doLast { fun Project.resolveDependencies( vararg dependency: String, 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 index 4974638d2a5f0..df07424e01386 100644 --- a/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/setupV8.kt +++ b/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/setupV8.kt @@ -2,8 +2,11 @@ * 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.gradle.kotlin.dsl.the import org.jetbrains.kotlin.gradle.targets.js.d8.D8RootExtension import org.jetbrains.kotlin.gradle.targets.js.d8.D8RootPlugin import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension @@ -13,7 +16,8 @@ private object V8Utils { lateinit var d8Plugin: D8RootExtension fun useD8Plugin(project: Project) { - d8Plugin = D8RootPlugin.apply(project.rootProject) + project.rootProject.plugins.apply(D8RootPlugin::class.java) + d8Plugin = project.rootProject.the() d8Plugin.version = project.v8Version } } @@ -22,6 +26,7 @@ fun Project.useD8Plugin() { V8Utils.useD8Plugin(this) } +@Suppress("DEPRECATION") fun Test.setupV8() { dependsOn(V8Utils.d8Plugin.setupTaskProvider) val v8ExecutablePath = project.provider {