Skip to content

Commit

Permalink
[Wasm] Deprecate JS infrastructure declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgonmic authored and qodana-bot committed Oct 16, 2024
1 parent e01850b commit 2d28a11
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 34 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions libraries/stdlib/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -254,7 +254,8 @@ kotlin {
}
}

D8RootPlugin.apply(rootProject).version = v8Version
rootProject.plugins.apply(D8RootPlugin::class.java)
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.d8.D8RootExtension>().version = v8Version

fun KotlinWasmTargetDsl.commonWasmTargetConfiguration() {
(this as KotlinTargetWithNodeJsDsl).nodejs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
<JsEngine> {
Expand All @@ -33,6 +27,13 @@ kotlin {
}
}

rootProject.plugins.apply(org.jetbrains.kotlin.gradle.targets.js.d8.D8Plugin::class.java)
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.d8.D8RootExtension>().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<org.jetbrains.kotlin.gradle.targets.js.npm.LockCopyTask>("kotlinStorePackageLock") {
//A little hacky way to make yarn results
inputFile.fileValue(projectDir.resolve("packageLockStub"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -29,6 +23,13 @@ kotlin {
}
}

rootProject.plugins.apply(org.jetbrains.kotlin.gradle.targets.js.d8.D8Plugin::class.java)
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.d8.D8RootExtension>().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<org.jetbrains.kotlin.gradle.targets.js.npm.LockCopyTask>("kotlinStorePackageLock") {
//A little hacky way to make yarn results
inputFile.fileValue(projectDir.resolve("packageLockStub"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ abstract class AbstractSettings<Env : AbstractEnv> : ConfigurationPhaseAware<Env

internal abstract val downloadProperty: org.gradle.api.provider.Property<Boolean>

// 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) {
Expand All @@ -35,8 +34,7 @@ abstract class AbstractSettings<Env : AbstractEnv> : ConfigurationPhaseAware<Env

internal abstract val installationDirectory: DirectoryProperty

// 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 corresponding spec (extension with name *Spec) instead. This will be removed in version 2.2.")
@Deprecated("This property has been migrated to support the Provider API. Use corresponding spec (extension with name *Spec) instead. This will be removed in version 2.2.")
var version: String
get() = versionProperty.get()
set(value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ open class D8Plugin : Plugin<Project> {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<D8RootExtension>()
d8Plugin.version = project.v8Version
}
}
Expand All @@ -22,6 +26,7 @@ fun Project.useD8Plugin() {
V8Utils.useD8Plugin(this)
}

@Suppress("DEPRECATION")
fun Test.setupV8() {
dependsOn(V8Utils.d8Plugin.setupTaskProvider)
val v8ExecutablePath = project.provider {
Expand Down

0 comments on commit 2d28a11

Please sign in to comment.