[Gradle, JS] Deprecation of BOTH and LEGACY consts
^KT-55593 fixed
This commit is contained in:
committed by
Space Team
parent
3744fbb31b
commit
a0211fc5fe
+4
@@ -8,8 +8,12 @@ package org.jetbrains.kotlin.gradle.plugin
|
||||
import java.util.*
|
||||
|
||||
enum class KotlinJsCompilerType {
|
||||
@Deprecated("Legacy compiler is deprecated. Migrate your project to the new IR-based compiler")
|
||||
LEGACY,
|
||||
|
||||
IR,
|
||||
|
||||
@Deprecated("Legacy compiler is deprecated. Migrate your project to the new IR-based compiler")
|
||||
BOTH;
|
||||
|
||||
companion object {
|
||||
|
||||
+4
@@ -3,6 +3,8 @@
|
||||
* 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")
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
|
||||
interface KotlinJsCompilerTypeHolder {
|
||||
@@ -12,12 +14,14 @@ interface KotlinJsCompilerTypeHolder {
|
||||
get() = compilerTypeFromProperties ?: KotlinJsCompilerType.IR
|
||||
|
||||
// Necessary to get rid of KotlinJsCompilerType import in build script
|
||||
@Deprecated("Legacy compiler is deprecated. Migrate your project to the new IR-based compiler")
|
||||
val LEGACY: KotlinJsCompilerType
|
||||
get() = KotlinJsCompilerType.LEGACY
|
||||
|
||||
val IR: KotlinJsCompilerType
|
||||
get() = KotlinJsCompilerType.IR
|
||||
|
||||
@Deprecated("Legacy compiler is deprecated. Migrate your project to the new IR-based compiler")
|
||||
val BOTH: KotlinJsCompilerType
|
||||
get() = KotlinJsCompilerType.BOTH
|
||||
}
|
||||
+1
@@ -224,6 +224,7 @@ class HierarchicalMppIT : KGPBaseTest() {
|
||||
@GradleTest
|
||||
@DisplayName("Works with published JS library")
|
||||
fun testHmppWithPublishedJsBothDependency(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
|
||||
@Suppress("DEPRECATION")
|
||||
publishThirdPartyLib(
|
||||
projectName = "hierarchical-mpp-with-js-published-modules/third-party-lib",
|
||||
withGranularMetadata = true,
|
||||
|
||||
+1
@@ -14,6 +14,7 @@ import org.junit.jupiter.api.DisplayName
|
||||
import javax.inject.Inject
|
||||
|
||||
abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean) : KGPBaseTest() {
|
||||
@Suppress("DEPRECATION")
|
||||
private val defaultJsOptions = BuildOptions.JsOptions(
|
||||
useIrBackend = irBackend,
|
||||
jsCompilerType = if (irBackend) KotlinJsCompilerType.IR else KotlinJsCompilerType.LEGACY,
|
||||
|
||||
+1
@@ -544,6 +544,7 @@ class Kotlin2JsGradlePluginIT : AbstractKotlin2JsGradlePluginIT(false) {
|
||||
|
||||
@JsGradlePluginTests
|
||||
abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) : KGPBaseTest() {
|
||||
@Suppress("DEPRECATION")
|
||||
private val defaultJsOptions = BuildOptions.JsOptions(
|
||||
useIrBackend = irBackend,
|
||||
jsCompilerType = if (irBackend) KotlinJsCompilerType.IR else KotlinJsCompilerType.LEGACY,
|
||||
|
||||
+31
-20
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.gradle.native.MPPNativeTargets
|
||||
import org.jetbrains.kotlin.gradle.native.transformNativeTestProject
|
||||
import org.jetbrains.kotlin.gradle.native.transformNativeTestProjectWithPluginDsl
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.ProjectLocalConfigurations
|
||||
import org.jetbrains.kotlin.gradle.plugin.lowerName
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmWithJavaTargetPreset
|
||||
@@ -257,46 +256,50 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test
|
||||
fun testLibAndAppJsLegacy() = doTestLibAndAppJsBothCompilers(
|
||||
"sample-lib",
|
||||
"sample-app",
|
||||
LEGACY
|
||||
KotlinJsCompilerType.LEGACY
|
||||
)
|
||||
|
||||
@Test
|
||||
fun testLibAndAppJsIr() = doTestLibAndAppJsBothCompilers(
|
||||
"sample-lib",
|
||||
"sample-app",
|
||||
IR
|
||||
KotlinJsCompilerType.IR
|
||||
)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test
|
||||
fun testLibAndAppJsBoth() = doTestLibAndAppJsBothCompilers(
|
||||
"sample-lib",
|
||||
"sample-app",
|
||||
BOTH
|
||||
KotlinJsCompilerType.BOTH
|
||||
)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test
|
||||
fun testLibAndAppWithGradleKotlinDslJsLegacy() = doTestLibAndAppJsBothCompilers(
|
||||
"sample-lib-gradle-kotlin-dsl",
|
||||
"sample-app-gradle-kotlin-dsl",
|
||||
LEGACY
|
||||
KotlinJsCompilerType.LEGACY
|
||||
)
|
||||
|
||||
@Test
|
||||
fun testLibAndAppWithGradleKotlinDslJsIr() = doTestLibAndAppJsBothCompilers(
|
||||
"sample-lib-gradle-kotlin-dsl",
|
||||
"sample-app-gradle-kotlin-dsl",
|
||||
IR
|
||||
KotlinJsCompilerType.IR
|
||||
)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test
|
||||
fun testLibAndAppWithGradleKotlinDslJsBoth() = doTestLibAndAppJsBothCompilers(
|
||||
"sample-lib-gradle-kotlin-dsl",
|
||||
"sample-app-gradle-kotlin-dsl",
|
||||
BOTH
|
||||
KotlinJsCompilerType.BOTH
|
||||
)
|
||||
|
||||
private fun doTestLibAndAppJsBothCompilers(
|
||||
@@ -307,14 +310,15 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
val libProject = transformProjectWithPluginsDsl(libProjectName, directoryPrefix = "both-js-lib-and-app")
|
||||
val appProject = transformProjectWithPluginsDsl(appProjectName, directoryPrefix = "both-js-lib-and-app")
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
val compileTasksNames =
|
||||
listOf(
|
||||
*(if (jsCompilerType != BOTH) {
|
||||
*(if (jsCompilerType != KotlinJsCompilerType.BOTH) {
|
||||
arrayOf("NodeJs")
|
||||
} else {
|
||||
arrayOf(
|
||||
"NodeJs${LEGACY.lowerName.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}",
|
||||
"NodeJs${IR.lowerName.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}",
|
||||
"NodeJs${KotlinJsCompilerType.LEGACY.lowerName.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}",
|
||||
"NodeJs${KotlinJsCompilerType.IR.lowerName.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}",
|
||||
)
|
||||
}),
|
||||
).map { ":compileKotlin$it" }
|
||||
@@ -329,7 +333,8 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
assertTasksExecuted(*compileTasksNames.toTypedArray(), ":allMetadataJar")
|
||||
|
||||
val groupDir = projectDir.resolve("repo/com/example")
|
||||
val jsExtension = if (jsCompilerType == LEGACY) "jar" else "klib"
|
||||
@Suppress("DEPRECATION")
|
||||
val jsExtension = if (jsCompilerType == KotlinJsCompilerType.LEGACY) "jar" else "klib"
|
||||
val jsJarName = "sample-lib-nodejs/1.0/sample-lib-nodejs-1.0.$jsExtension"
|
||||
val metadataJarName = "sample-lib/1.0/sample-lib-1.0.jar"
|
||||
|
||||
@@ -352,8 +357,9 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
when (jsCompilerType) {
|
||||
LEGACY -> {
|
||||
KotlinJsCompilerType.LEGACY -> {
|
||||
val jsJar = ZipFile(groupDir.resolve(jsJarName))
|
||||
val compiledJs = jsJar.getInputStream(jsJar.getEntry("sample-lib.js")).reader().readText()
|
||||
Assert.assertTrue("function id(" in compiledJs)
|
||||
@@ -361,10 +367,10 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
Assert.assertTrue("function expectedFun(" in compiledJs)
|
||||
Assert.assertTrue("function main(" in compiledJs)
|
||||
}
|
||||
IR -> {
|
||||
KotlinJsCompilerType.IR -> {
|
||||
groupDir.resolve(jsJarName).exists()
|
||||
}
|
||||
BOTH -> {}
|
||||
KotlinJsCompilerType.BOTH -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -386,7 +392,8 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
assertTasksExecuted(*compileTaskNames)
|
||||
|
||||
if (jsCompilerType == LEGACY) {
|
||||
@Suppress("DEPRECATION")
|
||||
if (jsCompilerType == KotlinJsCompilerType.LEGACY) {
|
||||
projectDir.resolve(targetClassesDir("nodeJs")).resolve("sample-app.js").readText().run {
|
||||
Assert.assertTrue(contains("console.info"))
|
||||
Assert.assertTrue(contains("function nodeJsMain("))
|
||||
@@ -401,10 +408,12 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
checkAppBuild(jsCompilerType)
|
||||
}
|
||||
|
||||
if (jsCompilerType == BOTH) {
|
||||
@Suppress("DEPRECATION")
|
||||
if (jsCompilerType == KotlinJsCompilerType.BOTH) {
|
||||
@Suppress("DEPRECATION")
|
||||
listOf(
|
||||
LEGACY,
|
||||
IR
|
||||
KotlinJsCompilerType.LEGACY,
|
||||
KotlinJsCompilerType.IR
|
||||
).forEach {
|
||||
build(
|
||||
"assemble",
|
||||
@@ -970,9 +979,10 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
val appProject = Project("sample-app", gradleVersion, "new-mpp-lib-and-app")
|
||||
|
||||
val buildOptions = hmppFlags.buildOptions
|
||||
@Suppress("DEPRECATION")
|
||||
libProject.build(
|
||||
"publish",
|
||||
options = buildOptions.copy(jsCompilerType = BOTH)
|
||||
options = buildOptions.copy(jsCompilerType = KotlinJsCompilerType.BOTH)
|
||||
) {
|
||||
assertSuccessful()
|
||||
}
|
||||
@@ -1013,7 +1023,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
|
||||
build(
|
||||
"printMetadataFiles",
|
||||
options = buildOptions.copy(jsCompilerType = IR)
|
||||
options = buildOptions.copy(jsCompilerType = KotlinJsCompilerType.IR)
|
||||
) {
|
||||
assertSuccessful()
|
||||
|
||||
@@ -1464,6 +1474,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
|
||||
@Test
|
||||
fun testJsDceInMpp() = with(Project("new-mpp-js-dce", gradleVersion)) {
|
||||
@Suppress("DEPRECATION")
|
||||
build(
|
||||
"runRhino",
|
||||
options = defaultBuildOptions().copy(warningMode = WarningMode.Summary, jsCompilerType = KotlinJsCompilerType.LEGACY)
|
||||
|
||||
+1
@@ -44,6 +44,7 @@ class VariantAwareDependenciesMppIT : BaseGradleIT() {
|
||||
assertContains(">> :${innerProject.projectName}:runtimeClasspath --> sample-lib-nodejs-1.0.klib")
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
gradleProperties().appendText(jsCompilerType(KotlinJsCompilerType.LEGACY))
|
||||
|
||||
testResolveAllConfigurations(
|
||||
|
||||
+18
-15
@@ -7,7 +7,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.attributes.AttributeContainer
|
||||
import org.gradle.api.attributes.Category
|
||||
import org.gradle.api.attributes.Usage
|
||||
@@ -21,8 +20,7 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.targets
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
|
||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.capitalizeAsciiOnly
|
||||
import java.util.Locale
|
||||
import java.util.*
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNotNull
|
||||
@@ -134,6 +132,7 @@ class ConfigurationsTest : MultiplatformExtensionTest() {
|
||||
fun `test js IR compilation dependencies`() {
|
||||
val project = buildProjectWithMPP {
|
||||
kotlin {
|
||||
@Suppress("DEPRECATION")
|
||||
js(BOTH)
|
||||
targets.withType<KotlinJsTarget> {
|
||||
irTarget!!.compilations.getByName("main").dependencies {
|
||||
@@ -167,6 +166,7 @@ class ConfigurationsTest : MultiplatformExtensionTest() {
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
@Suppress("DEPRECATION")
|
||||
js(BOTH)
|
||||
linuxX64("linux")
|
||||
android()
|
||||
@@ -193,6 +193,7 @@ class ConfigurationsTest : MultiplatformExtensionTest() {
|
||||
val project = buildProjectWithMPP {
|
||||
kotlin {
|
||||
jvm()
|
||||
@Suppress("DEPRECATION")
|
||||
js(BOTH)
|
||||
linuxX64("linux")
|
||||
}
|
||||
@@ -225,22 +226,24 @@ class ConfigurationsTest : MultiplatformExtensionTest() {
|
||||
class TestDisambiguationAttributePropagation {
|
||||
private val disambiguationAttribute = org.gradle.api.attributes.Attribute.of("disambiguationAttribute", String::class.java)
|
||||
|
||||
private val mppProject get() = buildProjectWithMPP {
|
||||
kotlin {
|
||||
jvm("plainJvm") {
|
||||
attributes { attribute(disambiguationAttribute, "plainJvm") }
|
||||
}
|
||||
private val mppProject
|
||||
get() = buildProjectWithMPP {
|
||||
kotlin {
|
||||
jvm("plainJvm") {
|
||||
attributes { attribute(disambiguationAttribute, "plainJvm") }
|
||||
}
|
||||
|
||||
jvm("jvmWithJava") {
|
||||
withJava()
|
||||
attributes { attribute(disambiguationAttribute, "jvmWithJava") }
|
||||
jvm("jvmWithJava") {
|
||||
withJava()
|
||||
attributes { attribute(disambiguationAttribute, "jvmWithJava") }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val javaProject get() = buildProject {
|
||||
project.plugins.apply("java-library")
|
||||
}
|
||||
private val javaProject
|
||||
get() = buildProject {
|
||||
project.plugins.apply("java-library")
|
||||
}
|
||||
|
||||
//NB: There is no "api" configuration registered by Java Plugin
|
||||
private val javaConfigurations = listOf(
|
||||
|
||||
+1
@@ -34,6 +34,7 @@ class KT55347JsProjectImport {
|
||||
fun `GranularMetadataTransformation should be accessible in pure js projects -- IR`() =
|
||||
`GranularMetadataTransformation should be accessible in pure js projects`(IR)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test
|
||||
fun `GranularMetadataTransformation should be accessible in pure js projects -- BOTH`() =
|
||||
`GranularMetadataTransformation should be accessible in pure js projects`(BOTH)
|
||||
|
||||
Reference in New Issue
Block a user