diff --git a/libraries/tools/kotlin-gradle-plugin-api/api/kotlin-gradle-plugin-api.api b/libraries/tools/kotlin-gradle-plugin-api/api/kotlin-gradle-plugin-api.api index a8ca5b443a5..75d228fc8cd 100644 --- a/libraries/tools/kotlin-gradle-plugin-api/api/kotlin-gradle-plugin-api.api +++ b/libraries/tools/kotlin-gradle-plugin-api/api/kotlin-gradle-plugin-api.api @@ -980,18 +980,18 @@ public final class org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType$Compa } public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder { - public abstract fun getBOTH ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; + public abstract synthetic fun getBOTH ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; public abstract fun getCompilerTypeFromProperties ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; public abstract fun getDefaultJsCompilerType ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; public abstract fun getIR ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; - public abstract fun getLEGACY ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; + public abstract synthetic fun getLEGACY ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; } public final class org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder$DefaultImpls { - public static fun getBOTH (Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; + public static synthetic fun getBOTH (Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; public static fun getDefaultJsCompilerType (Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; public static fun getIR (Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; - public static fun getLEGACY (Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; + public static synthetic fun getLEGACY (Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; } public final class org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeKt { diff --git a/libraries/tools/kotlin-gradle-plugin-api/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType.kt b/libraries/tools/kotlin-gradle-plugin-api/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType.kt index c570bcb7d51..718a0fafc07 100644 --- a/libraries/tools/kotlin-gradle-plugin-api/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType.kt +++ b/libraries/tools/kotlin-gradle-plugin-api/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType.kt @@ -30,9 +30,12 @@ enum class KotlinJsCompilerType { } } +@Deprecated("This method is planned to be removed") val KotlinJsCompilerType.lowerName get() = name.toLowerCase(Locale.ENGLISH) +@Suppress("DEPRECATION") +@Deprecated("This method is planned to be removed") fun String.removeJsCompilerSuffix(compilerType: KotlinJsCompilerType): String { val truncatedString = removeSuffix(compilerType.lowerName) if (this != truncatedString) { diff --git a/libraries/tools/kotlin-gradle-plugin-api/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder.kt b/libraries/tools/kotlin-gradle-plugin-api/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder.kt index b2173cab7bc..7a45da3798e 100644 --- a/libraries/tools/kotlin-gradle-plugin-api/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder.kt +++ b/libraries/tools/kotlin-gradle-plugin-api/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder.kt @@ -8,20 +8,21 @@ package org.jetbrains.kotlin.gradle.plugin interface KotlinJsCompilerTypeHolder { + @Deprecated("Because only IR compiler is left, no more necessary to know about compiler type in properties") val compilerTypeFromProperties: KotlinJsCompilerType? val defaultJsCompilerType: KotlinJsCompilerType - get() = compilerTypeFromProperties ?: KotlinJsCompilerType.IR + get() = 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") + @Deprecated("Legacy compiler is deprecated. Migrate your project to the new IR-based compiler", level = DeprecationLevel.HIDDEN) 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") + @Deprecated("Legacy compiler is deprecated. Migrate your project to the new IR-based compiler", level = DeprecationLevel.HIDDEN) val BOTH: KotlinJsCompilerType get() = KotlinJsCompilerType.BOTH } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt index b7613ff8c86..22b2c7a4dd1 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt @@ -13,7 +13,6 @@ import org.gradle.util.GradleVersion import org.jetbrains.kotlin.cli.common.CompilerSystemProperties.COMPILE_INCREMENTAL_WITH_ARTIFACT_TRANSFORM import org.jetbrains.kotlin.gradle.model.ModelContainer import org.jetbrains.kotlin.gradle.model.ModelFetcherBuildAction -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.report.BuildReportType import org.jetbrains.kotlin.gradle.testbase.* import org.jetbrains.kotlin.gradle.util.* @@ -248,13 +247,12 @@ abstract class BaseGradleIT { } // the second parameter is for using with ToolingAPI, that do not like --daemon/--no-daemon options at all - data class BuildOptions constructor( + data class BuildOptions( val withDaemon: Boolean = false, val daemonOptionSupported: Boolean = true, val incremental: Boolean? = null, val incrementalJs: Boolean? = null, val incrementalJsKlib: Boolean? = null, - val jsIrBackend: Boolean? = null, val androidHome: File? = null, val javaHome: File? = null, val gradleUserHome: File? = null, @@ -269,7 +267,6 @@ abstract class BaseGradleIT { val withBuildCache: Boolean = false, val kaptOptions: KaptOptions? = null, val parallelTasksInProject: Boolean = false, - val jsCompilerType: KotlinJsCompilerType? = null, val configurationCache: Boolean = false, val configurationCacheProblems: ConfigurationCacheProblems = ConfigurationCacheProblems.FAIL, val warningMode: WarningMode = WarningMode.Fail, @@ -881,9 +878,6 @@ abstract class BaseGradleIT { } options.incrementalJs?.let { add("-Pkotlin.incremental.js=$it") } options.incrementalJsKlib?.let { add("-Pkotlin.incremental.js.klib=$it") } - options.jsIrBackend?.let { add("-Pkotlin.js.useIrBackend=$it") } - // because we have legacy compiler tests, we need nowarn for compiler testing - add("-Pkotlin.js.compiler.nowarn=true") options.usePreciseJavaTracking?.let { add("-Pkotlin.incremental.usePreciseJavaTracking=$it") } options.useClasspathSnapshot?.let { add("-P${COMPILE_INCREMENTAL_WITH_ARTIFACT_TRANSFORM.property}=$it") } options.androidGradlePluginVersion?.let { add("-Pandroid_tools_version=$it") } @@ -915,10 +909,6 @@ abstract class BaseGradleIT { if (options.parallelTasksInProject) add("--parallel") else add("--no-parallel") - options.jsCompilerType?.let { - add("-Pkotlin.js.compiler=$it") - } - if (options.dryRun) { add("--dry-run") } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/ExecutionStrategyIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/ExecutionStrategyIT.kt index 95f4d8c8d65..9fdf585fbee 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/ExecutionStrategyIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/ExecutionStrategyIT.kt @@ -21,6 +21,12 @@ class ExecutionStrategyJsIT : ExecutionStrategyIT() { ) + """ | + |kotlin { + | js { + | + | } + |} + | |afterEvaluate { | tasks.named('compileKotlinJs') { | kotlinOptions.outputFile = "${'$'}{project.projectDir}/web/js/" diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/HierarchicalMppIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/HierarchicalMppIT.kt index 33f9d8d0d11..213711299c6 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/HierarchicalMppIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/HierarchicalMppIT.kt @@ -10,7 +10,6 @@ import org.gradle.testkit.runner.BuildResult import org.gradle.util.GradleVersion import org.jetbrains.kotlin.gradle.internals.MULTIPLATFORM_PROJECT_METADATA_JSON_FILE_NAME import org.jetbrains.kotlin.gradle.internals.parseKotlinSourceSetMetadataFromJson -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinProjectStructureMetadata import org.jetbrains.kotlin.gradle.plugin.mpp.ModuleDependencyIdentifier import org.jetbrains.kotlin.gradle.plugin.mpp.SourceSetMetadataLayout @@ -287,12 +286,11 @@ open class HierarchicalMppIT : KGPBaseTest() { @GradleTest @DisplayName("Works with published JS library") - fun testHmppWithPublishedJsBothDependency(gradleVersion: GradleVersion, @TempDir tempDir: Path) { + fun testHmppWithPublishedJsIrDependency(gradleVersion: GradleVersion, @TempDir tempDir: Path) { @Suppress("DEPRECATION") publishThirdPartyLib( projectName = "hierarchical-mpp-with-js-published-modules/third-party-lib", withGranularMetadata = true, - jsCompilerType = KotlinJsCompilerType.BOTH, gradleVersion = gradleVersion, localRepoDir = tempDir ) @@ -302,7 +300,7 @@ open class HierarchicalMppIT : KGPBaseTest() { "hierarchical-mpp-with-js-published-modules/my-lib-foo", gradleVersion, localRepoDir = tempDir, - buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions(jsCompilerType = KotlinJsCompilerType.IR)) + buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions()) ) ) { build("publish", "assemble") @@ -316,7 +314,7 @@ open class HierarchicalMppIT : KGPBaseTest() { nativeProject( projectName = "hierarchical-mpp-with-js-project-dependency", gradleVersion = gradleVersion, - buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions(jsCompilerType = KotlinJsCompilerType.IR)) + buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions()) ) ) { build("assemble") @@ -385,7 +383,6 @@ open class HierarchicalMppIT : KGPBaseTest() { private fun publishThirdPartyLib( projectName: String = "third-party-lib".withPrefix, withGranularMetadata: Boolean, - jsCompilerType: KotlinJsCompilerType = KotlinJsCompilerType.IR, gradleVersion: GradleVersion, localRepoDir: Path, beforePublishing: TestProject.() -> Unit = { } @@ -394,7 +391,7 @@ open class HierarchicalMppIT : KGPBaseTest() { projectName = projectName, gradleVersion = gradleVersion, localRepoDir = localRepoDir, - buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions(jsCompilerType = jsCompilerType)) + buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions()) ).apply { beforePublishing() diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/JsConfigurationCacheIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/JsConfigurationCacheIT.kt index e4cf5c4d5f8..f49b047aeb5 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/JsConfigurationCacheIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/JsConfigurationCacheIT.kt @@ -6,15 +6,13 @@ package org.jetbrains.kotlin.gradle import org.gradle.util.GradleVersion -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.testbase.* import org.junit.jupiter.api.DisplayName -abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean) : KGPBaseTest() { +@JsGradlePluginTests +abstract class JsIrConfigurationCacheIT : KGPBaseTest() { @Suppress("DEPRECATION") private val defaultJsOptions = BuildOptions.JsOptions( - useIrBackend = irBackend, - jsCompilerType = if (irBackend) KotlinJsCompilerType.IR else KotlinJsCompilerType.LEGACY, ) final override val defaultBuildOptions = @@ -47,7 +45,7 @@ abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean) ":app:packageJson", ":app:publicPackageJson", ":app:compileKotlinJs", - if (irBackend) ":app:compileProductionExecutableKotlinJs" else ":app:processDceKotlinJs", + ":app:compileProductionExecutableKotlinJs", ":app:browserProductionWebpack", ) ) @@ -68,7 +66,7 @@ abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean) assertTasksUpToDate( ":app:packageJson", ":app:publicPackageJson", - if (irBackend) ":app:compileProductionExecutableKotlinJs" else ":app:processDceKotlinJs", + ":app:compileProductionExecutableKotlinJs", ":app:browserProductionWebpack", ) } @@ -88,7 +86,7 @@ abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean) ":rootPackageJson", ":compileKotlinJs", ":nodeTest", - ) + if (irBackend) listOf(":compileProductionExecutableKotlinJs") else emptyList() + ) + listOf(":compileProductionExecutableKotlinJs") ) } } @@ -110,7 +108,7 @@ abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean) ":rootPackageJson", ":compileKotlinJs", ":nodeTest", - ) + if (irBackend) listOf(":compileProductionExecutableKotlinJs") else emptyList() + ) + listOf(":compileProductionExecutableKotlinJs") assertTasksUpToDate(*upToDateTasks.toTypedArray()) } } @@ -151,9 +149,3 @@ abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean) } } } - -@JsGradlePluginTests -class JsConfigurationCacheIT : AbstractJsConfigurationCacheIT(irBackend = false) - -@JsGradlePluginTests -class JsIrConfigurationCacheIT : AbstractJsConfigurationCacheIT(irBackend = true) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/JsSetupConfigurationCacheIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/JsSetupConfigurationCacheIT.kt index 2794c7663e8..60eebb57e2b 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/JsSetupConfigurationCacheIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/JsSetupConfigurationCacheIT.kt @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.gradle import org.gradle.util.GradleVersion -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.testbase.* import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.condition.OS @@ -18,15 +17,9 @@ import org.junit.jupiter.api.condition.OS @OsCondition(supportedOn = [OS.LINUX, OS.MAC, OS.WINDOWS], enabledOnCI = [OS.LINUX, OS.MAC, OS.WINDOWS]) @NativeGradlePluginTests class JsSetupConfigurationCacheIT : KGPBaseTest() { - @Suppress("DEPRECATION") - private val defaultJsOptions = BuildOptions.JsOptions( - useIrBackend = true, - jsCompilerType = KotlinJsCompilerType.IR - ) override val defaultBuildOptions = super.defaultBuildOptions.copy( - jsOptions = defaultJsOptions, configurationCache = true, configurationCacheProblems = BaseGradleIT.ConfigurationCacheProblems.FAIL ) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt index f9dd9cc23c6..a8d2bf28cd0 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt @@ -10,7 +10,6 @@ import com.google.gson.JsonNull import com.google.gson.JsonObject import org.gradle.testkit.runner.BuildResult import org.gradle.util.GradleVersion -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.targets.js.dsl.Distribution import org.jetbrains.kotlin.gradle.targets.js.ir.KLIB_TYPE import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject @@ -22,8 +21,6 @@ import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockCopyTask.Companion.YA import org.jetbrains.kotlin.gradle.tasks.USING_JS_IR_BACKEND_MESSAGE import org.jetbrains.kotlin.gradle.testbase.* import org.jetbrains.kotlin.gradle.testbase.TestVersions.Gradle.G_7_6 -import org.jetbrains.kotlin.gradle.util.jsCompilerType -import org.jetbrains.kotlin.gradle.util.normalizePath import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.condition.DisabledIf import java.nio.file.Files @@ -33,7 +30,7 @@ import kotlin.streams.toList import kotlin.test.* @JsGradlePluginTests -class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) { +class Kotlin2JsIrGradlePluginIT : KGPBaseTest() { @DisplayName("TS type declarations are generated") @GradleTest @@ -245,7 +242,7 @@ class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) { assertEquals( setOf( - projectPath.resolve("build/js/packages/kotlin-js-browser-app/kotlin/kotlin-js-browser-base-js-ir.mjs").toFile(), + projectPath.resolve("build/js/packages/kotlin-js-browser-app/kotlin/kotlin-js-browser-base.mjs").toFile(), projectPath.resolve("build/js/packages/kotlin-js-browser-app/kotlin/foo/foo.txt").toFile(), ), modified.toSet() @@ -682,145 +679,9 @@ class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) { } } } -} - -@JsGradlePluginTests -class Kotlin2JsGradlePluginIT : AbstractKotlin2JsGradlePluginIT(false) { - @DisplayName("builtins are loaded") - @GradleTest - fun testKotlinJsBuiltins(gradleVersion: GradleVersion) { - project("kotlinBuiltins", gradleVersion) { - subProject("app").buildGradle.modify { originalScript -> - buildString { - append( - originalScript.replace( - "id \"org.jetbrains.kotlin.jvm\"", - "id \"org.jetbrains.kotlin.js\"" - ) - ) - append( - """ - | - |afterEvaluate { - | tasks.named('compileKotlinJs') { - | kotlinOptions.outputFile = "${'$'}{project.projectDir}/out/out.js" - | kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" - | } - |} - | - """.trimMargin() - ) - } - } - build("build") - } - } - - @DisplayName("js files from dependency are installed") - @GradleTest - fun testKotlinJsDependencyWithJsFiles(gradleVersion: GradleVersion) { - project("kotlin-js-dependency-with-js-files", gradleVersion) { - build("packageJson") { - val dependency = "2p-parser-core" - val version = "0.11.1" - - val dependencyDirectory = projectPath.resolve("build/js/packages_imported/$dependency/$version") - assertDirectoryExists(dependencyDirectory) - - val packageJson = dependencyDirectory - .resolve(NpmProject.PACKAGE_JSON) - .let { - Gson().fromJson(it.readText(), PackageJson::class.java) - } - - assertEquals(dependency, packageJson.name) - assertEquals(version, packageJson.version) - assertEquals("$dependency.js", packageJson.main) - } - } - } - - @DisplayName("DCE in dev mode replaces outdated dependencies on incremental build") - @GradleTest - fun testIncrementalDceDevModeOnExternalDependency(gradleVersion: GradleVersion) { - project("kotlin-js-browser-project", gradleVersion) { - buildGradleKts.modify(::transformBuildScriptWithPluginsDsl) - - build(":base:jsLegacyJar") - - val baseSubproject = subProject("base") - val libSubproject = subProject("lib") - val baseJar = baseSubproject.projectPath.resolve("build/libs/base-legacy.jar") - val originalBaseJar = libSubproject.projectPath.resolve("base.1.jar") - val modifiedBaseJar = libSubproject.projectPath.resolve("base.2.jar") - Files.copy(baseJar, originalBaseJar) - - baseSubproject.kotlinSourcesDir().resolve("Base.kt").appendText( - """ - | - |fun bestRandom() = 4 - """.trimMargin() - ) - - build(":base:jsLegacyJar") - - Files.copy(baseJar, modifiedBaseJar) - - val baseBuildscript = baseSubproject.buildGradleKts - val libBuildscript = libSubproject.buildGradleKts - baseBuildscript.modify { - it.replace("js(\"both\")", "js(\"both\") { moduleName = \"base2\" }") - } - libBuildscript.modify { - it.replace("implementation(project(\":base\"))", "implementation(files(\"${normalizePath(originalBaseJar.toString())}\"))") - } - libBuildscript.appendText( - """ - | - |kotlin.js().browser { - | dceTask { - | dceOptions.devMode = true - | } - |} - """.trimMargin() - ) - - val baseDceFile = projectPath.resolve("build/js/packages/kotlin-js-browser-lib/kotlin-dce/kotlin-js-browser-base-js-legacy.js") - - build(":lib:processDceKotlinJs") { - assertFileDoesNotContain(baseDceFile, "bestRandom") - } - - libBuildscript.modify { - it.replace(normalizePath(originalBaseJar.toString()), normalizePath(modifiedBaseJar.toString())) - } - - build(":lib:processDceKotlinJs") { - assertFileContains(baseDceFile, "bestRandom") - } - } - } -} - -@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, - ) - - final override val defaultBuildOptions = - super.defaultBuildOptions.copy( - jsOptions = defaultJsOptions, - ) protected fun BuildResult.checkIrCompilationMessage() { - if (irBackend) { - assertOutputContains(USING_JS_IR_BACKEND_MESSAGE) - } else { - assertOutputDoesNotContain(USING_JS_IR_BACKEND_MESSAGE) - } + assertOutputContains(USING_JS_IR_BACKEND_MESSAGE) } @DisplayName("js customized output is included into jar") @@ -854,11 +715,8 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) ":compileKotlin2Js", ":compileTestKotlin2Js" ) - if (irBackend) { - assertFileInProjectExists("build/kotlin2js/main/default/manifest") - } else { - assertFileInProjectExists("build/kotlin2js/main/module.js") - } + assertFileInProjectExists("build/kotlin2js/main/default/manifest") + assertFileInProjectExists("build/kotlin2js/test/module-tests.js") } } @@ -878,44 +736,42 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) @GradleTest fun testKotlinJsSourceMap(gradleVersion: GradleVersion) { project("kotlin2JsProjectWithSourceMap", gradleVersion) { - build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") { - if (irBackend) { - val appSourceMap = subProject("app").projectPath - .resolve("build/compileSync/js/main/developmentExecutable/kotlin/$projectName-app.js.map") - assertFileContains( - appSourceMap, - "\"../../../../../../src/main/kotlin/main.kt\"", - "\"../../../../../../../lib/src/main/kotlin/foo.kt\"", - "\"sourcesContent\":[null", - ) + build("compileDevelopmentExecutableKotlinJs") { + val appSourceMap = subProject("app").projectPath + .resolve("build/compileSync/js/main/developmentExecutable/kotlin/$projectName-app.js.map") + assertFileContains( + appSourceMap, + "\"../../../../../../src/main/kotlin/main.kt\"", + "\"../../../../../../../lib/src/main/kotlin/foo.kt\"", + "\"sourcesContent\":[null", + ) - // The default should be generating simple names. - assertFileContains(appSourceMap, "somewhereOverTheRainbow") - assertFileDoesNotContain(appSourceMap, "\"names\":[]") - assertFileDoesNotContain(appSourceMap, "app.C.somewhereOverTheRainbow") + // The default should be generating simple names. + assertFileContains(appSourceMap, "somewhereOverTheRainbow") + assertFileDoesNotContain(appSourceMap, "\"names\":[]") + assertFileDoesNotContain(appSourceMap, "app.C.somewhereOverTheRainbow") - val libSourceMap = subProject("app").projectPath - .resolve("build/compileSync/js/main/developmentExecutable/kotlin/$projectName-lib.js.map") - assertFileContains( - libSourceMap, - "\"../../../../../../../lib/src/main/kotlin/foo.kt\"", - "\"sourcesContent\":[null", - ) + val libSourceMap = subProject("app").projectPath + .resolve("build/compileSync/js/main/developmentExecutable/kotlin/$projectName-lib.js.map") + assertFileContains( + libSourceMap, + "\"../../../../../../../lib/src/main/kotlin/foo.kt\"", + "\"sourcesContent\":[null", + ) - // The default should be generating simple names. - assertFileDoesNotContain(libSourceMap, "\"names\":[]") + // The default should be generating simple names. + assertFileDoesNotContain(libSourceMap, "\"names\":[]") - val libSourceMap2 = projectPath - .resolve("build/js/packages/$projectName-app/kotlin/$projectName-lib.js.map") - assertFileContains( - libSourceMap2, - "\"../../../../../lib/src/main/kotlin/foo.kt\"", - "\"sourcesContent\":[null", - ) + val libSourceMap2 = projectPath + .resolve("build/js/packages/$projectName-app/kotlin/$projectName-lib.js.map") + assertFileContains( + libSourceMap2, + "\"../../../../../lib/src/main/kotlin/foo.kt\"", + "\"sourcesContent\":[null", + ) - // The default should be generating simple names. - assertFileDoesNotContain(libSourceMap2, "\"names\":[]") - } + // The default should be generating simple names. + assertFileDoesNotContain(libSourceMap2, "\"names\":[]") assertFileContains( projectPath .resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js.map"), @@ -927,50 +783,11 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) } } - @DisplayName("prefix is added to paths in source map") - @DisabledIf( - "org.jetbrains.kotlin.gradle.AbstractKotlin2JsGradlePluginIT#getIrBackend", - disabledReason = "Source maps are not supported in IR backend" - ) - @GradleTest - fun testKotlinJsSourceMapCustomPrefix(gradleVersion: GradleVersion) { - project("kotlin2JsProjectWithSourceMap", gradleVersion) { - buildGradleKts.appendText( - """ - |project("app") { - | tasks.withType { - | kotlinOptions.sourceMapPrefix = "appPrefix/" - | } - |} - | - |project("lib") { - | tasks.withType { - | kotlinOptions.sourceMapPrefix = "libPrefix/" - | } - |} - | - """.trimMargin() - ) - build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") { - val mapFilePath = projectPath - .resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js.map") - assertFileContains( - mapFilePath, - "\"appPrefix/src/main/kotlin/main.kt\"", - "\"appPrefix/libPrefix/src/main/kotlin/foo.kt\"", - ) - } - } - } - @DisplayName("path in source maps are remapped for custom outputFile") @GradleTest fun testKotlinJsSourceMapCustomOutputFile(gradleVersion: GradleVersion) { project("kotlin2JsProjectWithSourceMap", gradleVersion) { - val taskSelector = if (irBackend) - "named(\"compileDevelopmentExecutableKotlinJs\")" - else - "withType" + val taskSelector = "named(\"compileDevelopmentExecutableKotlinJs\")" buildGradleKts.appendText( """ |project("app") { @@ -981,17 +798,12 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) | """.trimMargin() ) - build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") { + build("compileDevelopmentExecutableKotlinJs") { val mapFilePath = subProject("app").projectPath .resolve("build/kotlin2js/app.js.map") assertFileContains(mapFilePath, "\"../../src/main/kotlin/main.kt\"") - if (irBackend) { - // The IR BE generates correct paths for dependencies - assertFileContains(mapFilePath, "\"../../../lib/src/main/kotlin/foo.kt\"") - } else { - // The legacy BE doesn't. - assertFileContains(mapFilePath, "\"../../../../../lib/src/main/kotlin/foo.kt\"") - } + // The IR BE generates correct paths for dependencies + assertFileContains(mapFilePath, "\"../../../lib/src/main/kotlin/foo.kt\"") } } } @@ -1010,7 +822,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) | """.trimMargin() ) - build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") { + build("compileDevelopmentExecutableKotlinJs") { val jsFilePath = projectPath.resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js") assertFileExists(jsFilePath) assertFileNotExists(Path("$jsFilePath.map")) @@ -1040,7 +852,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) | """.trimMargin() ) - build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") { + build("compileDevelopmentExecutableKotlinJs") { val mapFilePath = projectPath.resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js.map") assertFileContains( mapFilePath, @@ -1073,7 +885,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) | """.trimMargin() ) - build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") { + build("compileDevelopmentExecutableKotlinJs") { val mapFilePath = projectPath.resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js.map") assertFileDoesNotContain( mapFilePath, @@ -1089,24 +901,19 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) @DisplayName("smoke test of org.jetbrains.kotlin.js plugin") @GradleTest - @DisabledIf( - "org.jetbrains.kotlin.gradle.AbstractKotlin2JsGradlePluginIT#getIrBackend", - disabledReason = "kotlinx.html doesn't support IR" - ) fun testNewKotlinJsPlugin(gradleVersion: GradleVersion) { project("kotlin-js-plugin-project", gradleVersion) { - build("publish", "processDceKotlinJs", "test", "processDceBenchmarkKotlinJs") { + build("publish", "assemble", "test", "compileBenchmarkKotlinJs") { assertTasksExecuted( - ":compileKotlinJs", ":compileTestKotlinJs", ":compileBenchmarkKotlinJs", - ":processDceKotlinJs", ":processDceBenchmarkKotlinJs" + ":compileKotlinJs", ":compileTestKotlinJs", ":compileBenchmarkKotlinJs" ) val moduleDir = projectPath.resolve("build/repo/com/example/kotlin-js-plugin/1.0/") - val publishedJar = moduleDir.resolve("kotlin-js-plugin-1.0.jar") + val publishedJar = moduleDir.resolve("kotlin-js-plugin-1.0.klib") ZipFile(publishedJar.toFile()).use { zip -> val entries = zip.entries().asSequence().map { it.name } - assertTrue { "kotlin-js-plugin.js" in entries } + assertTrue { "default/manifest" in entries } } val publishedPom = moduleDir.resolve("kotlin-js-plugin-1.0.pom") @@ -1117,17 +924,6 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) assertFileExists(moduleDir.resolve("kotlin-js-plugin-1.0-sources.jar")) - assertFileInProjectExists("build/js/node_modules/kotlin/kotlin.js") - assertFileInProjectExists("build/js/node_modules/kotlin/kotlin.js.map") - assertFileInProjectExists("build/js/node_modules/kotlin-test/kotlin-test.js") - assertFileInProjectExists("build/js/node_modules/kotlin-test/kotlin-test.js.map") - assertFileInProjectExists("build/js/node_modules/kotlin-test-js-runner/kotlin-test-nodejs-runner.js") - assertFileInProjectExists("build/js/node_modules/kotlin-test-js-runner/kotlin-test-nodejs-runner.js.map") - assertFileInProjectExists("build/js/node_modules/kotlin-js-plugin/kotlin/kotlin-js-plugin.js") - assertFileInProjectExists("build/js/node_modules/kotlin-js-plugin/kotlin/kotlin-js-plugin.js.map") - assertFileInProjectExists("build/js/node_modules/kotlin-js-plugin-test/kotlin/kotlin-js-plugin-test.js") - assertFileInProjectExists("build/js/node_modules/kotlin-js-plugin-test/kotlin/kotlin-js-plugin-test.js.map") - assertTestResults(projectPath.resolve("tests.xml"), "nodeTest") } } @@ -1182,7 +978,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) build("jsJar") { val archive = projectPath .resolve("build/libs") - .allFilesWithExtension(if (irBackend) KLIB_TYPE else "jar") + .allFilesWithExtension(KLIB_TYPE) .single() ZipFile(archive.toFile()).use { zipFile -> @@ -1253,7 +1049,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) build("jsJar") { val archive = Files.list(projectPath.resolve("build").resolve("libs")).use { files -> files - .filter { it.extension == if (irBackend) KLIB_TYPE else "jar" } + .filter { it.extension == KLIB_TYPE } .toList() .single() } @@ -1278,59 +1074,31 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) project("kotlin-js-browser-project", gradleVersion) { buildGradleKts.modify(::transformBuildScriptWithPluginsDsl) - if (irBackend) { - gradleProperties.appendText(jsCompilerType(KotlinJsCompilerType.IR)) - } - - if (irBackend) { - build("compileProductionExecutableKotlinJs") { - assertTasksExecuted(":app:compileProductionExecutableKotlinJs") - assert(task(":kotlinNpmInstall") == null) { - printBuildOutput() - "NPM install should not be run" - } + build("compileProductionExecutableKotlinJs") { + assertTasksExecuted(":app:compileProductionExecutableKotlinJs") + assert(task(":kotlinNpmInstall") == null) { + printBuildOutput() + "NPM install should not be run" } } build("assemble") { assertTasksExecuted(":app:browserProductionWebpack") - assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-base-js-ir") - assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-base-js-legacy") + assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-base") assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-lib") assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-app") - if (irBackend) { - assertFileInProjectExists("app/build/${Distribution.DIST}/js/productionExecutable/app.js") - } else { - assertFileInProjectExists("app/build/distributions/app.js") - } - - if (!irBackend) { - assertTasksExecuted(":app:processDceKotlinJs") - - assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-app/kotlin-dce") - - assertFileInProjectExists("build/js/packages/kotlin-js-browser-app/kotlin-dce/kotlin.js") - assertFileInProjectExists("build/js/packages/kotlin-js-browser-app/kotlin-dce/kotlin-js-browser-app.js") - assertFileInProjectExists("build/js/packages/kotlin-js-browser-app/kotlin-dce/kotlin-js-browser-lib.js") - assertFileInProjectExists("build/js/packages/kotlin-js-browser-app/kotlin-dce/kotlin-js-browser-base-js-legacy.js") - - assertFileInProjectExists("app/build/distributions/app.js.map") - } + assertFileInProjectExists("app/build/${Distribution.DIST}/js/productionExecutable/app.js") } build("clean", "browserDistribution") { assertTasksExecuted( ":app:processResources", - if (irBackend) ":app:browserProductionExecutableDistributeResources" else ":app:browserDistributeResources" + ":app:browserProductionExecutableDistributeResources" ) - if (irBackend) { - assertFileInProjectExists("app/build/${Distribution.DIST}/js/productionExecutable/index.html") - } else { - assertFileInProjectExists("app/build/distributions/index.html") - } + assertFileInProjectExists("app/build/${Distribution.DIST}/js/productionExecutable/index.html") } } } @@ -1359,22 +1127,6 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) } } - @DisplayName("kotlin/js compiler warning") - @GradleTest - fun testKotlinJsCompilerWarn(gradleVersion: GradleVersion) { - project( - "kotlin-js-compiler-warn", - gradleVersion, - buildOptions = defaultBuildOptions.copy(jsOptions = defaultJsOptions.copy(compileNoWarn = false, jsCompilerType = null)) - ) { - buildGradleKts.modify(::transformBuildScriptWithPluginsDsl) - - build("assemble") { - assertOutputDoesNotContain("This project currently uses the Kotlin/JS Legacy") - } - } - } - @DisplayName("NodeJs test with custom fork options") @GradleTest fun testNodeJsForkOptions(gradleVersion: GradleVersion) { @@ -1791,19 +1543,6 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) } } } -} - -@JsGradlePluginTests -class GeneralKotlin2JsGradlePluginIT : KGPBaseTest() { - @DisplayName("js with both backends mode builds successfully") - @GradleTest - fun testJsBothModeWithTests(gradleVersion: GradleVersion) { - project("kotlin-js-both-mode-with-tests", gradleVersion) { - build("build") { - assertNoBuildWarnings(setOf("w: 'kotlin-js' Gradle plugin is deprecated and will be removed in the future.")) - } - } - } @DisplayName("nodejs up-to-date check works") @GradleTest @@ -1900,4 +1639,28 @@ class GeneralKotlin2JsGradlePluginIT : KGPBaseTest() { } } } + + @DisplayName("js files from dependency are installed") + @GradleTest + fun testKotlinJsDependencyWithJsFiles(gradleVersion: GradleVersion) { + project("kotlin-js-dependency-with-js-files", gradleVersion) { + build("packageJson") { + val dependency = "2p-parser-core" + val version = "0.11.1" + + val dependencyDirectory = projectPath.resolve("build/js/packages_imported/$dependency/$version") + assertDirectoryExists(dependencyDirectory) + + val packageJson = dependencyDirectory + .resolve(NpmProject.PACKAGE_JSON) + .let { + Gson().fromJson(it.readText(), PackageJson::class.java) + } + + assertEquals(dependency, packageJson.name) + assertEquals(version, packageJson.version) + assertEquals("$dependency.js", packageJson.main) + } + } + } } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsIrBeIncrementalCompilationIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsIrBeIncrementalCompilationIT.kt index 2ede32d99cb..81726ef259b 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsIrBeIncrementalCompilationIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsIrBeIncrementalCompilationIT.kt @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.gradle import org.gradle.util.GradleVersion -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.testbase.* import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.DisplayName @@ -38,7 +37,6 @@ class Kotlin2FirJsIrBeIncrementalCompilationIT : Kotlin2JsIrBeIncrementalCompila open class Kotlin2JsIrBeIncrementalCompilationIT : KGPBaseTest() { override val defaultBuildOptions = BuildOptions( jsOptions = BuildOptions.JsOptions( - jsCompilerType = KotlinJsCompilerType.IR, incrementalJsKlib = true, incrementalJsIr = true ), diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsDomApiDependencyIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsDomApiDependencyIT.kt index 8aeb529026e..a2c1cb2edec 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsDomApiDependencyIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsDomApiDependencyIT.kt @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.gradle import org.gradle.util.GradleVersion -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.testbase.* import org.junit.jupiter.api.DisplayName @@ -14,8 +13,6 @@ import org.junit.jupiter.api.DisplayName class KotlinJsDomApiDependencyIT : KGPBaseTest() { private val defaultJsOptions = BuildOptions.JsOptions( - useIrBackend = true, - jsCompilerType = KotlinJsCompilerType.IR ) override val defaultBuildOptions = diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsIncrementalGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsIncrementalGradlePluginIT.kt index feb5f6417af..4c72596fe7a 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsIncrementalGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsIncrementalGradlePluginIT.kt @@ -8,13 +8,10 @@ package org.jetbrains.kotlin.gradle import org.gradle.api.logging.LogLevel import org.gradle.testkit.runner.BuildResult import org.gradle.util.GradleVersion -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.tasks.USING_JS_INCREMENTAL_COMPILATION_MESSAGE import org.jetbrains.kotlin.gradle.tasks.USING_JS_IR_BACKEND_MESSAGE import org.jetbrains.kotlin.gradle.testbase.* import org.junit.jupiter.api.DisplayName -import kotlin.io.path.* -import kotlin.test.* @JsGradlePluginTests open class KotlinJsIr10IncrementalGradlePluginIT : AbstractKotlinJsIncrementalGradlePluginIT( @@ -29,19 +26,12 @@ class KotlinJsFirIncrementalGradlePluginIT : KotlinJsIr10IncrementalGradlePlugin ) } -@JsGradlePluginTests -open class KotlinJsLegacy10IncrementalGradlePluginIT : AbstractKotlinJsIncrementalGradlePluginIT( - irBackend = false -) - @JsGradlePluginTests abstract class AbstractKotlinJsIncrementalGradlePluginIT( protected val irBackend: Boolean ) : KGPBaseTest() { @Suppress("DEPRECATION") private val defaultJsOptions = BuildOptions.JsOptions( - useIrBackend = irBackend, - jsCompilerType = if (irBackend) KotlinJsCompilerType.IR else KotlinJsCompilerType.LEGACY ) override val defaultBuildOptions = diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsLibraryGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsLibraryGradlePluginIT.kt index 899bc813c61..5bec07ecc98 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsLibraryGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsLibraryGradlePluginIT.kt @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.gradle import com.google.gson.Gson import com.google.gson.JsonObject import org.gradle.util.GradleVersion -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.targets.js.dsl.Distribution.Companion.DIST import org.jetbrains.kotlin.gradle.testbase.* import org.junit.jupiter.api.DisplayName @@ -21,8 +20,6 @@ abstract class KotlinJsIrLibraryGradlePluginITBase : KGPBaseTest() { override val defaultBuildOptions = super.defaultBuildOptions.copy( jsOptions = BuildOptions.JsOptions( - useIrBackend = true, - jsCompilerType = KotlinJsCompilerType.IR ) ) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinSpecificDependenciesIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinSpecificDependenciesIT.kt index 5fa3740226f..8b090396784 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinSpecificDependenciesIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinSpecificDependenciesIT.kt @@ -86,6 +86,9 @@ class KotlinSpecificDependenciesIT : KGPBaseTest() { gradleProperties.appendText( "\nkotlin.stdlib.default.dependency=false" ) + gradleProperties.appendText( + "\nkotlin.js.stdlib.dom.api.included=false" + ) checkTaskCompileClasspath( "compileKotlinJs", listOf(), diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt index e4e7d75b996..472ec3d1ec8 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt @@ -14,10 +14,8 @@ import org.jetbrains.kotlin.gradle.native.* 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.ProjectLocalConfigurations import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnostics -import org.jetbrains.kotlin.gradle.plugin.lowerName import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin import org.jetbrains.kotlin.gradle.plugin.sources.METADATA_CONFIGURATION_NAME_SUFFIX import org.jetbrains.kotlin.gradle.plugin.sources.UnsatisfiedSourceSetVisibilityException @@ -257,72 +255,27 @@ open class NewMultiplatformIT : BaseGradleIT() { } } - @Suppress("DEPRECATION") - @Test - fun testLibAndAppJsLegacy() = doTestLibAndAppJsBothCompilers( - "sample-lib", - "sample-app", - KotlinJsCompilerType.LEGACY - ) - @Test fun testLibAndAppJsIr() = doTestLibAndAppJsBothCompilers( "sample-lib", "sample-app", - KotlinJsCompilerType.IR - ) - - @Suppress("DEPRECATION") - @Test - fun testLibAndAppJsBoth() = doTestLibAndAppJsBothCompilers( - "sample-lib", - "sample-app", - KotlinJsCompilerType.BOTH - ) - - @Suppress("DEPRECATION") - @Test - fun testLibAndAppWithGradleKotlinDslJsLegacy() = doTestLibAndAppJsBothCompilers( - "sample-lib-gradle-kotlin-dsl", - "sample-app-gradle-kotlin-dsl", - KotlinJsCompilerType.LEGACY ) @Test fun testLibAndAppWithGradleKotlinDslJsIr() = doTestLibAndAppJsBothCompilers( "sample-lib-gradle-kotlin-dsl", "sample-app-gradle-kotlin-dsl", - KotlinJsCompilerType.IR - ) - - @Suppress("DEPRECATION") - @Test - fun testLibAndAppWithGradleKotlinDslJsBoth() = doTestLibAndAppJsBothCompilers( - "sample-lib-gradle-kotlin-dsl", - "sample-app-gradle-kotlin-dsl", - KotlinJsCompilerType.BOTH ) private fun doTestLibAndAppJsBothCompilers( libProjectName: String, appProjectName: String, - jsCompilerType: KotlinJsCompilerType, ) { 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 != KotlinJsCompilerType.BOTH) { - arrayOf("NodeJs") - } else { - arrayOf( - "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" } + val compileTasksNames = listOf(":compileKotlinNodeJs") with(libProject) { gradleProperties().appendText( @@ -333,7 +286,7 @@ open class NewMultiplatformIT : BaseGradleIT() { ) build( "publish", - options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType) + options = defaultBuildOptions() ) { assertSuccessful() assertTasksNotExecuted(":compileCommonMainKotlinMetadata") @@ -342,7 +295,7 @@ open class NewMultiplatformIT : BaseGradleIT() { val groupDir = projectDir.resolve("repo/com/example") @Suppress("DEPRECATION") - val jsExtension = if (jsCompilerType == KotlinJsCompilerType.LEGACY) "jar" else "klib" + val jsExtension = "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" @@ -365,21 +318,7 @@ open class NewMultiplatformIT : BaseGradleIT() { ) } - @Suppress("DEPRECATION") - when (jsCompilerType) { - 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) - Assert.assertTrue("function idUsage(" in compiledJs) - Assert.assertTrue("function expectedFun(" in compiledJs) - Assert.assertTrue("function main(" in compiledJs) - } - KotlinJsCompilerType.IR -> { - groupDir.resolve(jsJarName).exists() - } - KotlinJsCompilerType.BOTH -> {} - } + groupDir.resolve(jsJarName).exists() } } @@ -398,46 +337,17 @@ open class NewMultiplatformIT : BaseGradleIT() { // we use `maven { setUrl(...) }` because this syntax actually works both for Groovy and Kotlin DSLs in Gradle gradleBuildScript().appendText("\nrepositories { maven { setUrl(\"$libLocalRepoUri\") } }") - fun CompiledProject.checkAppBuild(compilerType: KotlinJsCompilerType) { + fun CompiledProject.checkAppBuild() { assertSuccessful() - val compileTaskNames = if (jsCompilerType == compilerType) { - compileTasksNames.toTypedArray() - } else { - arrayOf(":compileKotlinNodeJs") - } - assertTasksExecuted(*compileTaskNames) - @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(")) - } - } + assertTasksExecuted(compileTasksNames) } build( "assemble", - options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType) + options = defaultBuildOptions() ) { - checkAppBuild(jsCompilerType) - } - - @Suppress("DEPRECATION") - if (jsCompilerType == KotlinJsCompilerType.BOTH) { - @Suppress("DEPRECATION") - listOf( - KotlinJsCompilerType.LEGACY, - KotlinJsCompilerType.IR - ).forEach { - build( - "assemble", - "--rerun-tasks", - options = defaultBuildOptions().copy(jsCompilerType = it) - ) { - checkAppBuild(it) - } - } + checkAppBuild() } // Now run again with a project dependency instead of a module one: @@ -453,9 +363,9 @@ open class NewMultiplatformIT : BaseGradleIT() { "clean", "assemble", "--rerun-tasks", - options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType) + options = defaultBuildOptions() ) { - checkAppBuild(jsCompilerType) + checkAppBuild() } } } @@ -1021,7 +931,7 @@ open class NewMultiplatformIT : BaseGradleIT() { @Suppress("DEPRECATION") libProject.build( "publish", - options = buildOptions.copy(jsCompilerType = KotlinJsCompilerType.BOTH) + options = buildOptions ) { assertSuccessful() } @@ -1063,25 +973,6 @@ open class NewMultiplatformIT : BaseGradleIT() { } """.trimIndent() ) - - build( - "printMetadataFiles", - options = buildOptions.copy(jsCompilerType = KotlinJsCompilerType.IR) - ) { - // After introducing Resolvable Metadata Dependencies configuration - // resolving nodeJsMainResolvableDependenciesMetadata is expected to fail for dependencies that have published - // both Legacy and IR klibs. - // Previously these Metadata Dependencies Configurations got resolved into platform artifacts which is incorrect - // and is just result of gradle's attempt to resolve to anything. - // TODO: Remove this test after removing Resolvable Metadata Dependencies for platform source sets. - assertFailed() - - assertContains( - "However we cannot choose between the following variants of com.example:sample-lib-nodejs:1.0:", - "- nodeJsIrApiElements-published", - "- nodeJsLegacyApiElements-published", - ) - } } } @@ -1518,34 +1409,6 @@ open class NewMultiplatformIT : BaseGradleIT() { } } - @Test - fun testJsDceInMpp() = with(Project("new-mpp-js-dce", gradleVersion)) { - setupWorkingDir() - gradleProperties().appendText( - """ - - kotlin.compiler.execution.strategy=in-process - """.trimIndent() - ) - - @Suppress("DEPRECATION") - build( - "runRhino", - options = defaultBuildOptions().copy(jsCompilerType = KotlinJsCompilerType.LEGACY) - ) { - assertSuccessful() - assertTasksExecuted(":mainProject:processDceBrowserKotlinJs") - - val pathPrefix = "mainProject/build/kotlin-js-min/" - assertFileExists("$pathPrefix/exampleapp.js.map") - assertFileExists("$pathPrefix/examplelib.js.map") - assertFileContains("$pathPrefix/exampleapp.js.map", "\"../../src/browserMain/kotlin/exampleapp/main.kt\"") - - assertFileExists("$pathPrefix/kotlin.js") - assertTrue(fileInWorkingDir("$pathPrefix/kotlin.js").length() < 500 * 1000, "Looks like kotlin.js file was not minified by DCE") - } - } - @Test fun testDefaultSourceSetsDsl() = with(Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")) { setupWorkingDir() diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesMppIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesMppIT.kt index 94451fc37cd..0106d68577c 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesMppIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesMppIT.kt @@ -6,8 +6,6 @@ package org.jetbrains.kotlin.gradle import org.gradle.util.GradleVersion -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType -import org.jetbrains.kotlin.gradle.testbase.TestVersions import org.jetbrains.kotlin.gradle.util.* import org.junit.Test import kotlin.test.assertTrue @@ -41,13 +39,6 @@ class VariantAwareDependenciesMppIT : BaseGradleIT() { testResolveAllConfigurations(subproject = innerProject.projectName) { assertContains(">> :${innerProject.projectName}:runtimeClasspath --> sample-lib-nodejs-1.0.klib") } - - @Suppress("DEPRECATION") - gradleProperties().appendText(jsCompilerType(KotlinJsCompilerType.LEGACY)) - - testResolveAllConfigurations(subproject = innerProject.projectName, skipSetup = true) { - assertContains(">> :${innerProject.projectName}:runtimeClasspath --> sample-lib-nodejs-1.0.jar") - } } } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/WasmConfigurationCacheIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/WasmConfigurationCacheIT.kt index e107a3da670..f1f3e9effee 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/WasmConfigurationCacheIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/WasmConfigurationCacheIT.kt @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.gradle import org.gradle.util.GradleVersion -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.testbase.* import org.junit.jupiter.api.DisplayName diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/BuildOptions.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/BuildOptions.kt index 11fe8b16c11..f124ade0322 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/BuildOptions.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/BuildOptions.kt @@ -11,7 +11,6 @@ import org.gradle.util.GradleVersion import org.jetbrains.kotlin.cli.common.CompilerSystemProperties.COMPILE_INCREMENTAL_WITH_ARTIFACT_TRANSFORM import org.jetbrains.kotlin.gradle.BaseGradleIT import org.jetbrains.kotlin.gradle.dsl.NativeCacheKind -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.report.BuildReportType import org.junit.jupiter.api.condition.OS import java.util.* @@ -57,12 +56,9 @@ data class BuildOptions( ) data class JsOptions( - val useIrBackend: Boolean? = null, - val jsCompilerType: KotlinJsCompilerType? = null, val incrementalJs: Boolean? = null, val incrementalJsKlib: Boolean? = null, - val incrementalJsIr: Boolean? = null, - val compileNoWarn: Boolean = true, + val incrementalJsIr: Boolean? = null ) data class NativeOptions( @@ -141,14 +137,6 @@ data class BuildOptions( jsOptions.incrementalJs?.let { arguments.add("-Pkotlin.incremental.js=$it") } jsOptions.incrementalJsKlib?.let { arguments.add("-Pkotlin.incremental.js.klib=$it") } jsOptions.incrementalJsIr?.let { arguments.add("-Pkotlin.incremental.js.ir=$it") } - jsOptions.useIrBackend?.let { arguments.add("-Pkotlin.js.useIrBackend=$it") } - jsOptions.jsCompilerType?.let { arguments.add("-Pkotlin.js.compiler=$it") } - // because we have legacy compiler tests, we need nowarn for compiler testing - if (jsOptions.compileNoWarn) { - arguments.add("-Pkotlin.js.compiler.nowarn=true") - } - } else { - arguments.add("-Pkotlin.js.compiler.nowarn=true") } if (androidVersion != null) { diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/util/jsCompilerType.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/util/jsCompilerType.kt deleted file mode 100644 index 83fac5e7f68..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/util/jsCompilerType.kt +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright 2010-2020 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.gradle.util - -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType - -fun jsCompilerType(compilerType: KotlinJsCompilerType) = - "\n${KotlinJsCompilerType.jsCompilerProperty}=$compilerType" \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/appleSilicon/gradle.properties b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/appleSilicon/gradle.properties index 49b91dfd07a..29e08e8ca88 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/appleSilicon/gradle.properties +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/appleSilicon/gradle.properties @@ -1,2 +1 @@ -kotlin.code.style=official -kotlin.js.generate.executable.default=false \ No newline at end of file +kotlin.code.style=official \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/both-js-lib-and-app/sample-app-gradle-kotlin-dsl/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/both-js-lib-and-app/sample-app-gradle-kotlin-dsl/build.gradle.kts index 914eff1ee94..5778e491118 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/both-js-lib-and-app/sample-app-gradle-kotlin-dsl/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/both-js-lib-and-app/sample-app-gradle-kotlin-dsl/build.gradle.kts @@ -25,8 +25,4 @@ kotlin { } } } -} - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/both-js-lib-and-app/sample-app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/both-js-lib-and-app/sample-app/build.gradle index 01255839fd4..fc9abf9282f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/both-js-lib-and-app/sample-app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/both-js-lib-and-app/sample-app/build.gradle @@ -32,8 +32,4 @@ kotlin { } } } -} - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/both-js-lib-and-app/sample-lib-gradle-kotlin-dsl/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/both-js-lib-and-app/sample-lib-gradle-kotlin-dsl/build.gradle.kts index cc2ebaded5b..41458b8a6d0 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/both-js-lib-and-app/sample-lib-gradle-kotlin-dsl/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/both-js-lib-and-app/sample-lib-gradle-kotlin-dsl/build.gradle.kts @@ -40,8 +40,4 @@ publishing { repositories { maven { setUrl("file://${projectDir.absolutePath.replace('\\', '/')}/repo") } } -} - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/both-js-lib-and-app/sample-lib/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/both-js-lib-and-app/sample-lib/build.gradle index d84ba47b47a..14ede40215a 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/both-js-lib-and-app/sample-lib/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/both-js-lib-and-app/sample-lib/build.gradle @@ -53,8 +53,4 @@ publishing { repositories { maven { url "file://${projectDir.absolutePath.replace('\\', '/')}/repo" } } -} - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonize-kt-48856-singleNativeTargetPropagation-testSourceSet/gradle.properties b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonize-kt-48856-singleNativeTargetPropagation-testSourceSet/gradle.properties index 791d96036d2..47309cda557 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonize-kt-48856-singleNativeTargetPropagation-testSourceSet/gradle.properties +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonize-kt-48856-singleNativeTargetPropagation-testSourceSet/gradle.properties @@ -1,4 +1,3 @@ kotlin.code.style=official -kotlin.js.generate.executable.default=false kotlin.mpp.enableCInteropCommonization=true kotlin.mpp.enableIntransitiveMetadataConfiguration=true diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeNativeDistributionWithIosLinuxWindows/gradle.properties b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeNativeDistributionWithIosLinuxWindows/gradle.properties index 8af57df28c1..29e08e8ca88 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeNativeDistributionWithIosLinuxWindows/gradle.properties +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/commonizeNativeDistributionWithIosLinuxWindows/gradle.properties @@ -1,2 +1 @@ -kotlin.code.style=official -kotlin.js.generate.executable.default=false +kotlin.code.style=official \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/differentClassloaders/gradle.properties b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/differentClassloaders/gradle.properties deleted file mode 100644 index 31585e0e8dd..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/differentClassloaders/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -kotlin.js.compiler=legacy diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/differentClassloaders/js-app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/differentClassloaders/js-app/build.gradle index 55554834cc8..f053813e896 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/differentClassloaders/js-app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/differentClassloaders/js-app/build.gradle @@ -11,6 +11,10 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-js" } +kotlin { + js() +} + if (project.findProperty("mppProjectDependency") == "true") { dependencies { @@ -27,8 +31,4 @@ if (project.findProperty("mppProjectDependency") == "true") { api "com.example:mpp-lib:1.0" } -} - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/differentClassloaders/mpp-lib/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/differentClassloaders/mpp-lib/build.gradle index 4bcd8feca16..686876fbf8f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/differentClassloaders/mpp-lib/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/differentClassloaders/mpp-lib/build.gradle @@ -39,8 +39,4 @@ publishing { repositories { maven { setUrl("${rootProject.buildDir}/repo") } } -} - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-js-test/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-js-test/build.gradle.kts index dafd7bf32be..7bd9da76e70 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-js-test/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-js-test/build.gradle.kts @@ -57,8 +57,4 @@ kotlin { } } } -} - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-published-modules/my-app/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-published-modules/my-app/build.gradle.kts index f27675c407c..dddf4b0fd6f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-published-modules/my-app/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-published-modules/my-app/build.gradle.kts @@ -86,8 +86,4 @@ kotlin { dependsOn(linuxAndJsTest) } } -} - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-published-modules/my-lib-bar/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-published-modules/my-lib-bar/build.gradle.kts index e030e422d74..4fb376f3b7c 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-published-modules/my-lib-bar/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-published-modules/my-lib-bar/build.gradle.kts @@ -93,8 +93,4 @@ publishing { repositories { maven("") } -} - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-published-modules/my-lib-foo/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-published-modules/my-lib-foo/build.gradle.kts index 234497b0ba4..5bdbc563bde 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-published-modules/my-lib-foo/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-published-modules/my-lib-foo/build.gradle.kts @@ -105,8 +105,4 @@ publishing { repositories { maven("") } -} - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-published-modules/third-party-lib/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-published-modules/third-party-lib/build.gradle.kts index 64ba7116a08..1dbee8d8c6f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-published-modules/third-party-lib/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-published-modules/third-party-lib/build.gradle.kts @@ -54,8 +54,4 @@ publishing { repositories { maven("") } -} - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-with-js-project-dependency/my-app/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-with-js-project-dependency/my-app/build.gradle.kts index 0ae4a7090a8..120368a028f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-with-js-project-dependency/my-app/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-with-js-project-dependency/my-app/build.gradle.kts @@ -40,8 +40,4 @@ kotlin { } } } -} - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-with-js-project-dependency/my-lib-foo/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-with-js-project-dependency/my-lib-foo/build.gradle.kts index a96e67faa2a..bd1879150a3 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-with-js-project-dependency/my-lib-foo/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-with-js-project-dependency/my-lib-foo/build.gradle.kts @@ -26,8 +26,4 @@ kotlin { } } } -} - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-with-js-published-modules/my-lib-foo/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-with-js-published-modules/my-lib-foo/build.gradle.kts index 134b7d8cfc1..ba353e0c943 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-with-js-published-modules/my-lib-foo/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-with-js-published-modules/my-lib-foo/build.gradle.kts @@ -35,8 +35,4 @@ publishing { repositories { maven("") } -} - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-with-js-published-modules/third-party-lib/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-with-js-published-modules/third-party-lib/build.gradle.kts index 0aebebf7c8e..b456ada095b 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-with-js-published-modules/third-party-lib/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/hierarchical-mpp-with-js-published-modules/third-party-lib/build.gradle.kts @@ -37,8 +37,4 @@ publishing { from(components["kotlin"]) } } -} - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/instantExecutionToJs/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/instantExecutionToJs/build.gradle index df87787d5b8..a58de639a31 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/instantExecutionToJs/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/instantExecutionToJs/build.gradle @@ -20,22 +20,12 @@ dependencies { testImplementation "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version" } -def jsUseIrBackend = project.findProperty("kotlin.js.useIrBackend")?.toBoolean() == true - tasks.named("compileKotlinJs", Kotlin2JsCompile) { it.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/module.js" - if (jsUseIrBackend) { - it.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"] - } else { - it.kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" - } + it.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"] } tasks.named("compileTestKotlinJs", Kotlin2JsCompile) { it.kotlinOptions.outputFile = "${buildDir}/kotlin2js/test/module-tests.js" - if (jsUseIrBackend) { - it.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"] - } else { - it.kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" - } + it.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"] } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/js-dynamic-webpack-config-d/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/js-dynamic-webpack-config-d/build.gradle.kts index 5fd88fe1440..fb790f69fe0 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/js-dynamic-webpack-config-d/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/js-dynamic-webpack-config-d/build.gradle.kts @@ -33,7 +33,4 @@ tasks.named("browserTest") { tasks.withType { dependsOn("foo") -} -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/jvmAndJsProject/jsLib/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/jvmAndJsProject/jsLib/build.gradle index e6294cb97b6..adb4a219312 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/jvmAndJsProject/jsLib/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/jvmAndJsProject/jsLib/build.gradle @@ -1,3 +1,7 @@ plugins { id "org.jetbrains.kotlin.js" } + +kotlin { + js() +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-both-mode-with-tests/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-both-mode-with-tests/build.gradle.kts deleted file mode 100644 index 85393a3e71f..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-both-mode-with-tests/build.gradle.kts +++ /dev/null @@ -1,23 +0,0 @@ -plugins { - kotlin("js") -} - -group = "com.example" -version = "1.0" - -repositories { - mavenLocal() - mavenCentral() -} - -kotlin { - @Suppress("DEPRECATION") - js(BOTH) { - nodejs { - } - } -} - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-both-mode-with-tests/gradle.properties b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-both-mode-with-tests/gradle.properties deleted file mode 100644 index ab0b07046d9..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-both-mode-with-tests/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -kotlin.js.compiler.nowarn=true \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-both-mode-with-tests/src/main/kotlin/app.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-both-mode-with-tests/src/main/kotlin/app.kt deleted file mode 100644 index de931e13178..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-both-mode-with-tests/src/main/kotlin/app.kt +++ /dev/null @@ -1 +0,0 @@ -fun foo() = 5 \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-both-mode-with-tests/src/test/kotlin/test.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-both-mode-with-tests/src/test/kotlin/test.kt deleted file mode 100644 index a2628a18fce..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-both-mode-with-tests/src/test/kotlin/test.kt +++ /dev/null @@ -1 +0,0 @@ -fun bar() = foo() \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-browser-project/app/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-browser-project/app/build.gradle.kts index af7f9b38db2..31310aa0692 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-browser-project/app/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-browser-project/app/build.gradle.kts @@ -71,13 +71,6 @@ rootProject.plugins.withType("compileKotlinJs") { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} -tasks.named("compileTestKotlinJs") { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} - tasks.withType().configureEach { kotlinOptions { moduleKind = "es" diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-browser-project/base/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-browser-project/base/build.gradle.kts index d19a9caaad0..066376cfe21 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-browser-project/base/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-browser-project/base/build.gradle.kts @@ -1,4 +1,4 @@ -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.BOTH as BOTH_TYPE +import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.IR as IR_TYPE plugins { kotlin("js") @@ -10,18 +10,11 @@ dependencies { @Suppress("DEPRECATION") kotlin { - js("both") - js(BOTH) - js(BOTH_TYPE) { + js("ir") + js(IR) + js(IR_TYPE) { useCommonJs() browser { } } -} - -tasks.named("compileKotlinJsLegacy") { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} -tasks.named("compileTestKotlinJsLegacy") { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-browser-project/lib/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-browser-project/lib/build.gradle.kts index 9a00c15952f..13ff08e22c3 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-browser-project/lib/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-browser-project/lib/build.gradle.kts @@ -13,11 +13,4 @@ kotlin { browser { } } -} - -tasks.named("compileKotlinJs") { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} -tasks.named("compileTestKotlinJs") { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-compiler-warn/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-compiler-warn/build.gradle.kts deleted file mode 100644 index 0cbcd5a6328..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-compiler-warn/build.gradle.kts +++ /dev/null @@ -1,23 +0,0 @@ -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.BOTH as BOTH_TYPE - -plugins { - kotlin("multiplatform") -} - -repositories { - mavenLocal() - mavenCentral() -} - -@Suppress("DEPRECATION") -kotlin { - js(BOTH) - js(BOTH_TYPE) { - useCommonJs() - browser { - } - } - js { - - } -} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-compiler-warn/settings.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-compiler-warn/settings.gradle deleted file mode 100644 index bb57e5ac101..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-compiler-warn/settings.gradle +++ /dev/null @@ -1,5 +0,0 @@ -rootProject.name = "kotlin-js-browser" - -include("base") -include("lib") -include("app") \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-coroutines/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-coroutines/build.gradle.kts index dac840eee8c..918c7054446 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-coroutines/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-coroutines/build.gradle.kts @@ -1,5 +1,3 @@ -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.BOTH as BOTH_TYPE - plugins { kotlin("multiplatform") } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-ir-ic-multiple-artifacts/app/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-ir-ic-multiple-artifacts/app/build.gradle.kts index 0ae96538b36..a8f7befb801 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-ir-ic-multiple-artifacts/app/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-ir-ic-multiple-artifacts/app/build.gradle.kts @@ -27,7 +27,4 @@ kotlin { } } } -} -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-ir-ic-multiple-artifacts/lib/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-ir-ic-multiple-artifacts/lib/build.gradle.kts index f5df9e771f2..6a42bd1cd12 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-ir-ic-multiple-artifacts/lib/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-ir-ic-multiple-artifacts/lib/build.gradle.kts @@ -35,7 +35,4 @@ kotlin { } } } -} -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-nodejs-custom-node-module/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-nodejs-custom-node-module/build.gradle index 32916ee88e2..c96daaf9db0 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-nodejs-custom-node-module/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-nodejs-custom-node-module/build.gradle @@ -24,8 +24,4 @@ kotlin { } } } -} - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-nodejs-project/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-nodejs-project/build.gradle index 38651cc19f3..a5ca83678fd 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-nodejs-project/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-nodejs-project/build.gradle @@ -19,11 +19,4 @@ kotlin { nodejs { } } -} - -tasks.named("compileKotlinJs", org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} -tasks.named("compileTestKotlinJs", org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-plugin-project/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-plugin-project/build.gradle.kts index 9aaf962f5cf..fcb40ca90be 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-plugin-project/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-plugin-project/build.gradle.kts @@ -57,7 +57,3 @@ publishing { maven("$buildDir/repo") } } - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-plugin-project/gradle.properties b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-plugin-project/gradle.properties index a07f193a2ff..d1af4310adb 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-plugin-project/gradle.properties +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-plugin-project/gradle.properties @@ -1,3 +1,2 @@ kotlin.tests.individualTaskReports=true #because of dependency (kotlinx-html) which is not klib yet -kotlin.js.compiler=legacy diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-test-webpack-config/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-test-webpack-config/build.gradle.kts index 32a499080e8..fb69510384c 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-test-webpack-config/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-test-webpack-config/build.gradle.kts @@ -64,8 +64,4 @@ kotlin { } } } -} - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsICProject/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsICProject/app/build.gradle index f4ca0b5eb78..ba7965e4037 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsICProject/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsICProject/app/build.gradle @@ -19,8 +19,4 @@ kotlin { } binaries.executable() } -} - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsICProject/lib/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsICProject/lib/build.gradle index ba741a03495..57cc932058b 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsICProject/lib/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsICProject/lib/build.gradle @@ -17,8 +17,4 @@ kotlin { } } -} - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsInternalTest/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsInternalTest/build.gradle index 32d56a0fbe2..f5b4f8f130f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsInternalTest/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsInternalTest/build.gradle @@ -25,8 +25,4 @@ kotlin { } } -} - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsModuleKind/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsModuleKind/build.gradle index 4842fb138d5..acbc392c723 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsModuleKind/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsModuleKind/build.gradle @@ -19,9 +19,7 @@ def outDir = "${buildDir}/kotlin2js/main/" compileKotlin2Js.kotlinOptions.moduleKind = "amd" compileKotlin2Js.kotlinOptions.outputFile = outDir + "app.js" -if (project.findProperty("kotlin.js.useIrBackend")?.toBoolean() == true) { - compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"] -} +compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"] repositories { mavenLocal() @@ -60,9 +58,4 @@ build.doLast { into "${buildDir}/kotlin2js/main/" } } - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} - runRhino.dependsOn build \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsNoOutputFileProject/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsNoOutputFileProject/build.gradle index d77cabe4e15..1e2ee75bb9c 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsNoOutputFileProject/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsNoOutputFileProject/build.gradle @@ -20,7 +20,5 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" } -if (project.findProperty("kotlin.js.useIrBackend")?.toBoolean() == true) { - compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"] - compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"] -} \ No newline at end of file +compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"] +compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"] \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProject/libraryProject/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProject/libraryProject/build.gradle index 58b6a00d420..3ecfabd0e9c 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProject/libraryProject/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProject/libraryProject/build.gradle @@ -31,17 +31,14 @@ def outDir = "${buildDir}/kotlin2js/main/" compileKotlin2Js.kotlinOptions.outputFile = outDir + "test-library.js" -def isIrBackend = project.findProperty("kotlin.js.useIrBackend")?.toBoolean() -if (isIrBackend) { - compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir"] -} +compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir"] jar { from sourceSets.main.allSource include "**/*.kt" from outDir - include (isIrBackend ? "**/*" : "**/*.js") + include ("**/*") manifest { attributes( diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProject/mainProject/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProject/mainProject/build.gradle index 16f07014e38..1f5081bc708 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProject/mainProject/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProject/mainProject/build.gradle @@ -25,9 +25,7 @@ compileKotlin2Js.kotlinOptions.outputFile = "${projectDir}/web/js/app.js" compileKotlin2Js.kotlinOptions.suppressWarnings = true compileKotlin2Js.kotlinOptions.verbose = true -if (project.findProperty("kotlin.js.useIrBackend")?.toBoolean() == true) { - compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"] -} +compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"] build.doLast { configurations.compile.each { File file -> diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithSourceMap/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithSourceMap/build.gradle.kts index bf897692e74..b25c18d4255 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithSourceMap/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithSourceMap/build.gradle.kts @@ -12,7 +12,7 @@ repositories { mavenCentral() } -allprojects { +subprojects { apply(plugin = "org.jetbrains.kotlin.js") repositories { @@ -21,29 +21,21 @@ allprojects { } } -val useIrBackend = (findProperty("kotlin.js.useIrBackend") as? String?)?.toBoolean() ?: false - -val backend = if (useIrBackend) { - KotlinJsCompilerType.IR -} else { - KotlinJsCompilerType.LEGACY +kotlin { + js() } project("lib") { kotlin { - js(backend) { + js { browser() } } - - tasks.withType() { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" - } } project("app") { kotlin { - js(backend) { + js { browser() binaries.executable() } @@ -51,11 +43,4 @@ project("app") { implementation(project(":lib")) } } - - tasks.withType() { - kotlinOptions { - sourceMap = true - freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" - } - } } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithTests/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithTests/build.gradle index 89ec03bf806..95a15d31fd8 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithTests/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithTests/build.gradle @@ -30,12 +30,6 @@ artifacts { compileTestKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/test/module-tests.js" -if (project.findProperty("kotlin.js.useIrBackend")?.toBoolean() == true) { - compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"] - compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"] - compileKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/" -} else { - compileKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/module.js" - compileKotlin2Js.kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" - compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} \ No newline at end of file +compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"] +compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"] +compileKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/" \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kt-27059-pom-rewriting/gradle.properties b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kt-27059-pom-rewriting/gradle.properties deleted file mode 100644 index a0b65881e1b..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kt-27059-pom-rewriting/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -kotlin.js.compiler=legacy \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kt-27059-pom-rewriting/js-app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kt-27059-pom-rewriting/js-app/build.gradle index 81a8458bdb0..233c9da7224 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kt-27059-pom-rewriting/js-app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kt-27059-pom-rewriting/js-app/build.gradle @@ -42,8 +42,4 @@ publishing { repositories { maven { setUrl("${rootProject.buildDir}/repo") } } -} - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kt-27059-pom-rewriting/mpp-lib/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kt-27059-pom-rewriting/mpp-lib/build.gradle index 4bcd8feca16..686876fbf8f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kt-27059-pom-rewriting/mpp-lib/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kt-27059-pom-rewriting/mpp-lib/build.gradle @@ -39,8 +39,4 @@ publishing { repositories { maven { setUrl("${rootProject.buildDir}/repo") } } -} - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kt-55071-compileSharedNative-withDefaultParameters/gradle.properties b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kt-55071-compileSharedNative-withDefaultParameters/gradle.properties index 780d7218a51..29e08e8ca88 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kt-55071-compileSharedNative-withDefaultParameters/gradle.properties +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kt-55071-compileSharedNative-withDefaultParameters/gradle.properties @@ -1,3 +1 @@ -kotlin.code.style=official -kotlin.js.generate.executable.default=false -kotlin.js.compiler=ir +kotlin.code.style=official \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android-agp-compatibility/gradle.properties b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android-agp-compatibility/gradle.properties index 3f07a62e3cd..b987ca73f70 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android-agp-compatibility/gradle.properties +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android-agp-compatibility/gradle.properties @@ -1,5 +1,4 @@ kotlin.code.style=official -kotlin.js.generate.executable.default=false # Test is about compatibility, only version 1 was available in previous versions kotlin.mpp.androidSourceSetLayoutVersion=1 \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android/app/build.gradle index 2db4532fb22..3dac7b0302f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android/app/build.gradle @@ -79,8 +79,4 @@ task printCompilerPluginOptions { println sourceSet.name + '=cp=>' + cp } } -} - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android/lib/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android/lib/build.gradle index dd0c3788247..bdb75bb149b 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android/lib/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android/lib/build.gradle @@ -97,8 +97,4 @@ publishing { url = uri("$buildDir/repo") } } -} - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/libraryProject/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/libraryProject/build.gradle deleted file mode 100644 index 575b243faac..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/libraryProject/build.gradle +++ /dev/null @@ -1,34 +0,0 @@ -plugins { - id("org.jetbrains.kotlin.multiplatform") -} - -repositories { - mavenLocal() - mavenCentral() -} - -kotlin { - js("nodeJs") { - nodejs() - } -} - -dependencies { - nodeJsMainApi "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" -} - -compileKotlinNodeJs.kotlinOptions.outputFile = "${buildDir}/examplelib.js" -compileKotlinNodeJs.kotlinOptions.sourceMap = true - -nodeJsJar { - from buildDir - include "**/*.js" - include "**/*.js.map" -} - -nodeJsJar.dependsOn(compileKotlinNodeJs) - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} - diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/libraryProject/src/nodeJsMain/kotlin/examplelib/lib.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/libraryProject/src/nodeJsMain/kotlin/examplelib/lib.kt deleted file mode 100644 index 70f59d4e7bc..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/libraryProject/src/nodeJsMain/kotlin/examplelib/lib.kt +++ /dev/null @@ -1,6 +0,0 @@ -package examplelib - -fun foo() = "foo" - -fun bar() = "bar" - diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/mainProject/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/mainProject/build.gradle deleted file mode 100644 index 4663fbce3f0..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/mainProject/build.gradle +++ /dev/null @@ -1,53 +0,0 @@ -plugins { - id("org.jetbrains.kotlin.multiplatform") -} - -repositories { - mavenLocal() - mavenCentral() -} - -kotlin { - js("browser") { - browser() - } -} - -dependencies { - def browserMainImplConfigName = - kotlin.getTargets().getByName("browser").getCompilations().getByName("main").getImplementationConfigurationName() - - add(browserMainImplConfigName, project(":libraryProject")) - add(browserMainImplConfigName, "org.jetbrains.kotlin:kotlin-stdlib-js") - add(browserMainImplConfigName, "org.mozilla:rhino:1.7.7.1") -} - -tasks.named('compileKotlinBrowser') { - kotlinOptions { - sourceMap = true - outputFile = "${buildDir}/web/exampleapp.js" - suppressWarnings = true - verbose = true - } -} - -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJsDce).configureEach { - keep("exampleapp.exampleapp.status") - destinationDirectory = project.layout.buildDirectory.dir("kotlin-js-min") -} - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} - -tasks.register("runRhino", JavaExec) { - dependsOn(tasks.named('processDceBrowserKotlinJs')) - classpath = kotlin.targets.browser.compilations.main.runtimeDependencyFiles - workingDir = "${buildDir}" - mainClass = 'org.mozilla.javascript.tools.shell.Main' - args = ["-opt", "-1", - "-f", "kotlin-js-min/kotlin.js", - "-f", "kotlin-js-min/examplelib.js", - "-f", "kotlin-js-min/exampleapp.js", - "-f", "../check.js"] -} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/mainProject/check.js b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/mainProject/check.js deleted file mode 100644 index 213b8394c17..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/mainProject/check.js +++ /dev/null @@ -1,6 +0,0 @@ -(function() { - var status = exampleapp.exampleapp.status; - if (status !== "foo") { - throw new Error("Unexpected status: " + status); - } -})(); diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/mainProject/src/browserMain/kotlin/exampleapp/main.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/mainProject/src/browserMain/kotlin/exampleapp/main.kt deleted file mode 100644 index 6c9550597d2..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/mainProject/src/browserMain/kotlin/exampleapp/main.kt +++ /dev/null @@ -1,9 +0,0 @@ -package exampleapp - -import examplelib.* - -var status = "failure" - -fun main(args: Array) { - status = foo() -} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/settings.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/settings.gradle deleted file mode 100644 index 9eeb29d9776..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-dce/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include 'mainProject', 'libraryProject' \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-tests/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-tests/build.gradle.kts index b47a3c4d6c8..214137a275e 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-tests/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-js-tests/build.gradle.kts @@ -23,8 +23,4 @@ kotlin { js("server") js("client") -} - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-klibs-with-same-name/gradle.properties b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-klibs-with-same-name/gradle.properties deleted file mode 100644 index f670486d55c..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-klibs-with-same-name/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -kotlin.js.compiler=ir diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-app/build.gradle index 8334ce0ae74..94786e60141 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-app/build.gradle @@ -91,8 +91,4 @@ tasks.register("resolveRuntimeDependencies", DefaultTask) { def configName = kotlin.targets.jvm6.compilations.main.runtimeDependencyConfigurationName configurations[configName].resolve() } -} - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-lib-gradle-kotlin-dsl/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-lib-gradle-kotlin-dsl/build.gradle.kts index 92bda9587c0..61596812abd 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-lib-gradle-kotlin-dsl/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-lib-gradle-kotlin-dsl/build.gradle.kts @@ -64,8 +64,4 @@ afterEvaluate { tasks["assemble"].dependsOn(compileKotlinTask) } } -} - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-lib/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-lib/build.gradle index 26bc6e4b4dd..6f583904819 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-lib/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-lib/build.gradle @@ -115,8 +115,4 @@ afterEvaluate { assemble.dependsOn compileKotlinTask } } -} - -tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/npm-dependencies/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/npm-dependencies/build.gradle.kts index 8b490b1ff24..c2f197e055c 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/npm-dependencies/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/npm-dependencies/build.gradle.kts @@ -36,8 +36,4 @@ kotlin.sourceSets { kotlin.target { nodejs() -} - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/simple-js-executable/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/simple-js-executable/build.gradle.kts index 49162dc5ed1..9bcf3e8b283 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/simple-js-executable/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/simple-js-executable/build.gradle.kts @@ -16,7 +16,3 @@ kotlin { nodejs() } } - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/simple-js-library/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/simple-js-library/build.gradle.kts index 9cac82ba7f3..2a193442fb8 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/simple-js-library/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/simple-js-library/build.gradle.kts @@ -24,7 +24,3 @@ kotlin { } } } - -tasks.withType { - kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage" -} diff --git a/libraries/tools/kotlin-gradle-plugin/api/kotlin-gradle-plugin.api b/libraries/tools/kotlin-gradle-plugin/api/kotlin-gradle-plugin.api index 0682a6cd9ea..67fa45af110 100644 --- a/libraries/tools/kotlin-gradle-plugin/api/kotlin-gradle-plugin.api +++ b/libraries/tools/kotlin-gradle-plugin/api/kotlin-gradle-plugin.api @@ -39,7 +39,7 @@ public abstract class org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtensi public fun getAndroidNativeTest (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider; public fun getAppleMain (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider; public fun getAppleTest (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider; - public fun getBOTH ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; + public synthetic fun getBOTH ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; public fun getCommonMain (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider; public fun getCommonTest (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider; public fun getCompilerTypeFromProperties ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; @@ -51,7 +51,7 @@ public abstract class org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtensi public fun getJsTest (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider; public fun getJvmMain (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider; public fun getJvmTest (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider; - public fun getLEGACY ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; + public synthetic fun getLEGACY ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType; public fun getLinuxMain (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider; public fun getLinuxTest (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider; public fun getMacosMain (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider; diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtension.kt index ff0c4264f9a..ac920b2e952 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtension.kt @@ -13,7 +13,6 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.plugin.* import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle.Stage.AfterFinaliseDsl -import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider import org.jetbrains.kotlin.gradle.plugin.hierarchy.KotlinHierarchyDslImpl import org.jetbrains.kotlin.gradle.plugin.mpp.* import javax.inject.Inject @@ -33,13 +32,14 @@ abstract class KotlinMultiplatformExtension final override val targets: NamedDomainObjectCollection = project.container(KotlinTarget::class.java) + @Deprecated("Because only IR compiler is left, no more necessary to know about compiler type in properties") + override val compilerTypeFromProperties: KotlinJsCompilerType? = null + internal suspend fun awaitTargets(): NamedDomainObjectCollection { AfterFinaliseDsl.await() return targets } - override val compilerTypeFromProperties: KotlinJsCompilerType? = project.kotlinPropertiesProvider.jsCompiler - private val presetExtension = project.objects.newInstance( DefaultTargetsFromPresetExtension::class.java, { this }, diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt index b695818122d..82308b2750c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt @@ -16,20 +16,16 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.internal.KOTLIN_BUILD_TOOLS_API_IMPL import org.jetbrains.kotlin.gradle.internal.KOTLIN_MODULE_GROUP import org.jetbrains.kotlin.gradle.plugin.* -import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsSingleTargetPreset import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinPm20ProjectExtension import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService -import org.jetbrains.kotlin.gradle.targets.js.calculateJsCompilerType import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrSingleTargetPreset import org.jetbrains.kotlin.gradle.tasks.CompileUsingKotlinDaemon import org.jetbrains.kotlin.gradle.tasks.withType import org.jetbrains.kotlin.gradle.utils.castIsolatedKotlinPluginClassLoaderAware import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryK2 -import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName import org.jetbrains.kotlin.konan.target.CompilerOutputKind import org.jetbrains.kotlin.statistics.metrics.StringMetrics import javax.inject.Inject @@ -232,10 +228,11 @@ abstract class KotlinJsProjectExtension(project: Project) : KotlinJsCompilerTypeHolder { lateinit var irPreset: KotlinJsIrSingleTargetPreset - lateinit var legacyPreset: KotlinJsSingleTargetPreset - private val targetSetObservers = mutableListOf<(KotlinJsTargetDsl?) -> Unit>() + @Deprecated("Because only IR compiler is left, no more necessary to know about compiler type in properties") + override val compilerTypeFromProperties: KotlinJsCompilerType? = null + // target is public property // Users can write kotlin.target and it should work // So call of target should init default configuration @@ -250,49 +247,6 @@ abstract class KotlinJsProjectExtension(project: Project) : targetSetObservers.add(observer) } - companion object { - internal fun reportJsCompilerMode(compilerType: KotlinJsCompilerType) { - when (compilerType) { - KotlinJsCompilerType.LEGACY -> KotlinBuildStatsService.getInstance()?.report(StringMetrics.JS_COMPILER_MODE, "legacy") - KotlinJsCompilerType.IR -> KotlinBuildStatsService.getInstance()?.report(StringMetrics.JS_COMPILER_MODE, "ir") - KotlinJsCompilerType.BOTH -> KotlinBuildStatsService.getInstance()?.report(StringMetrics.JS_COMPILER_MODE, "both") - } - } - - internal fun warnAboutDeprecatedCompiler(project: Project, compilerType: KotlinJsCompilerType) { - if (PropertiesProvider(project).jsCompilerNoWarn) return - val logger = project.logger - when (compilerType) { - KotlinJsCompilerType.LEGACY -> logger.warn(LEGACY_DEPRECATED) - KotlinJsCompilerType.IR -> {} - KotlinJsCompilerType.BOTH -> logger.warn(BOTH_DEPRECATED) - } - } - - private val LEGACY_DEPRECATED = - """ - | - |========== - |This project currently uses the Kotlin/JS Legacy compiler backend, which has been deprecated and will be removed in a future release. - | - |Please migrate the project to the new IR-based compiler (https://kotl.in/jsir). - |========== - | - """.trimMargin() - - private val BOTH_DEPRECATED = - """ - | - |========== - |This project currently uses Both mode, which requires the Kotlin/JS Legacy compiler backend. - |This backend has been deprecated and will be removed in a future release. - | - |Please migrate the project to the new IR-based compiler (https://kotl.in/jsir). - |========== - | - """.trimMargin() - } - @Deprecated("Use js() instead", ReplaceWith("js()")) @Suppress("DEPRECATION") override val target: KotlinJsTargetDsl @@ -303,50 +257,15 @@ abstract class KotlinJsProjectExtension(project: Project) : return _target!! } - override val compilerTypeFromProperties: KotlinJsCompilerType? = project.kotlinPropertiesProvider.jsCompiler - @Suppress("DEPRECATION") private fun jsInternal( compiler: KotlinJsCompilerType? = null, - body: KotlinJsTargetDsl.() -> Unit + body: KotlinJsTargetDsl.() -> Unit, ): KotlinJsTargetDsl { - if (_target != null) { - val previousCompilerType = _target!!.calculateJsCompilerType() - check(compiler == null || previousCompilerType == compiler) { - "You already registered Kotlin/JS target with another compiler: ${previousCompilerType.lowerName}" - } - } - if (_target == null) { - val compilerOrFromProperties = compiler ?: compilerTypeFromProperties - val compilerOrDefault = compilerOrFromProperties ?: defaultJsCompilerType - reportJsCompilerMode(compilerOrDefault) - warnAboutDeprecatedCompiler(project, compilerOrDefault) - val target: KotlinJsTargetDsl = when (compilerOrDefault) { - KotlinJsCompilerType.LEGACY -> legacyPreset - .also { - it.irPreset = null - } - .createTarget("js") - - KotlinJsCompilerType.IR -> irPreset - .also { - it.mixedMode = false - } - .createTarget("js") - - KotlinJsCompilerType.BOTH -> legacyPreset - .also { - irPreset.mixedMode = true - it.irPreset = irPreset - } - .createTarget( - lowerCamelCaseName( - "js", - LEGACY.lowerName - ) - ) - } + val compilerOrDefault = compiler ?: defaultJsCompilerType + val target: KotlinJsTargetDsl = irPreset + .createTarget("js") this._target = target @@ -360,19 +279,19 @@ abstract class KotlinJsProjectExtension(project: Project) : fun js( compiler: KotlinJsCompilerType = defaultJsCompilerType, - body: KotlinJsTargetDsl.() -> Unit = { } + body: KotlinJsTargetDsl.() -> Unit = { }, ): KotlinJsTargetDsl = jsInternal(compiler, body) fun js( compiler: String, - body: KotlinJsTargetDsl.() -> Unit = { } + body: KotlinJsTargetDsl.() -> Unit = { }, ): KotlinJsTargetDsl = js( KotlinJsCompilerType.byArgument(compiler), body ) fun js( - body: KotlinJsTargetDsl.() -> Unit = { } + body: KotlinJsTargetDsl.() -> Unit = { }, ) = jsInternal(body = body) fun js() = js { } @@ -411,7 +330,7 @@ abstract class KotlinCommonProjectExtension(project: Project) : KotlinSingleJava internal set open fun target( - body: KotlinWithJavaTarget.() -> Unit + body: KotlinWithJavaTarget.() -> Unit, ) = target.run(body) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithJsPresetFunctions.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithJsPresetFunctions.kt index c03e35bf91b..65cca3d79b3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithJsPresetFunctions.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithJsPresetFunctions.kt @@ -6,12 +6,8 @@ package org.jetbrains.kotlin.gradle.dsl import org.gradle.api.Action -import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension.Companion.reportJsCompilerMode -import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension.Companion.warnAboutDeprecatedCompiler import org.jetbrains.kotlin.gradle.plugin.* -import org.jetbrains.kotlin.gradle.targets.js.calculateJsCompilerType import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl -import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName @KotlinGradlePluginDsl interface KotlinTargetContainerWithJsPresetFunctions : @@ -84,74 +80,12 @@ private fun KotlinTargetContainerWithJsPresetFunctions.jsInternal( compiler: KotlinJsCompilerType? = null, configure: KotlinJsTargetDsl.() -> Unit ): KotlinJsTargetDsl { - val existingTarget = getExistingTarget(name, compiler) - - val kotlinJsCompilerType = (compiler - ?: existingTarget?.calculateJsCompilerType()) - - val compilerOrDefault = kotlinJsCompilerType - ?: defaultJsCompilerType - - val targetName = getTargetName(name, compilerOrDefault) - - if (existingTarget != null) { - val previousCompilerType = existingTarget.calculateJsCompilerType() - check(compiler == null || previousCompilerType == compiler) { - "You already registered Kotlin/JS target '$targetName' with another compiler: ${previousCompilerType.lowerName}" - } - } - - reportJsCompilerMode(compilerOrDefault) - @Suppress("UNCHECKED_CAST") return configureOrCreate( - targetName, + name, presets.getByName( - lowerCamelCaseName( - "js", - if (compilerOrDefault == KotlinJsCompilerType.LEGACY) null else compilerOrDefault.lowerName - ) + "js" ) as KotlinTargetPreset, configure - ).also { target -> - warnAboutDeprecatedCompiler(target.project, compilerOrDefault) - } -} - -// Try to find existing target with exact name -// and with append suffix Legacy in case when compiler for found target is BOTH, -// and removed suffix Legacy in case when current compiler is BOTH -private fun KotlinTargetContainerWithJsPresetFunctions.getExistingTarget( - name: String, - compiler: KotlinJsCompilerType? -): KotlinJsTargetDsl? { - - fun getPreviousTarget( - targetName: String, - currentBoth: Boolean - ): KotlinJsTargetDsl? { - val singleTarget = targets.findByName( - targetName - ) as KotlinJsTargetDsl? - - return singleTarget?.let { - val previousCompiler = it.calculateJsCompilerType() - if (compiler == KotlinJsCompilerType.BOTH && currentBoth || previousCompiler == KotlinJsCompilerType.BOTH && !currentBoth) { - it - } else null - } - } - - val targetNameCandidate = getTargetName(name, compiler) - - return targets.findByName(targetNameCandidate) as KotlinJsTargetDsl? - ?: getPreviousTarget(targetNameCandidate.removeJsCompilerSuffix(KotlinJsCompilerType.LEGACY), true) - ?: getPreviousTarget(lowerCamelCaseName(targetNameCandidate, KotlinJsCompilerType.LEGACY.lowerName), false) -} - -private fun getTargetName(name: String, compiler: KotlinJsCompilerType?): String { - return lowerCamelCaseName( - name, - if (compiler == KotlinJsCompilerType.BOTH) KotlinJsCompilerType.LEGACY.lowerName else null ) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/internal/kotlinDomApiDependencyManagement.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/internal/kotlinDomApiDependencyManagement.kt index f1e5881c3e2..0c071a10c90 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/internal/kotlinDomApiDependencyManagement.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/internal/kotlinDomApiDependencyManagement.kt @@ -18,7 +18,6 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.GradleKpmModule import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinPm20ProjectExtension import org.jetbrains.kotlin.gradle.plugin.sources.KotlinDependencyScope import org.jetbrains.kotlin.gradle.plugin.sources.sourceSetDependencyConfigurationByScope -import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrCompilation import org.jetbrains.kotlin.gradle.targets.js.npm.SemVer @@ -79,10 +78,6 @@ private fun KotlinTarget.addKotlinDomApiDependency( dependencies: DependencyHandler, coreLibrariesVersion: Provider ) { - if (this is KotlinJsTarget) { - irTarget?.addKotlinDomApiDependency(configurations, dependencies, coreLibrariesVersion) - } - compilations.configureEach { compilation -> if (compilation.platformType != KotlinPlatformType.js) return@configureEach if (compilation !is KotlinJsIrCompilation) return@configureEach diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginWrapper.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginWrapper.kt index 1a4e5451a61..9bd0ffd7e2c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginWrapper.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginWrapper.kt @@ -350,6 +350,7 @@ abstract class AbstractKotlinJsPluginWrapper : KotlinBasePluginWrapper() { override val projectExtensionClass: KClass get() = KotlinJsProjectExtension::class + @Suppress("DEPRECATION") override fun whenBuildEvaluated(project: Project) = project.runProjectConfigurationHealthCheck { val isJsTargetUninitialized = (project.kotlinExtension as KotlinJsProjectExtension) ._target == null diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinTargetConfigurator.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinTargetConfigurator.kt index 08c2c8a03be..64941b0f833 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinTargetConfigurator.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinTargetConfigurator.kt @@ -28,7 +28,6 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions import org.jetbrains.kotlin.gradle.plugin.internal.artifactTypeAttribute import org.jetbrains.kotlin.gradle.plugin.mpp.* import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute -import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget import org.jetbrains.kotlin.gradle.targets.js.KotlinWasmTargetAttribute import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget @@ -432,10 +431,6 @@ fun Configuration.usesPlatformOf(target: KotlinTarget): Configuration { val publishJsCompilerAttribute = PropertiesProvider(target.project).publishJsCompilerAttribute - if (publishJsCompilerAttribute && target is KotlinJsTarget) { - attributes.attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.legacy) - } - if (publishJsCompilerAttribute && target is KotlinJsIrTarget) { if (target.platformType == KotlinPlatformType.js) { attributes.attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.ir) diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/PropertiesProvider.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/PropertiesProvider.kt index 90f7b7ff7f6..8dce0874c28 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/PropertiesProvider.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/PropertiesProvider.kt @@ -242,9 +242,6 @@ internal class PropertiesProvider private constructor(private val project: Proje val wasmStabilityNoWarn: Boolean get() = booleanProperty("kotlin.wasm.stability.nowarn") ?: false - val jsCompilerNoWarn: Boolean - get() = booleanProperty("$jsCompilerProperty.nowarn") ?: false - val ignoreDisabledNativeTargets: Boolean? get() = booleanProperty(KOTLIN_NATIVE_IGNORE_DISABLED_TARGETS) @@ -447,27 +444,12 @@ internal class PropertiesProvider private constructor(private val project: Proje val errorJsGenerateExternals: Boolean? get() = booleanProperty("kotlin.js.generate.externals") - /** - * Use Kotlin/JS backend compiler type - */ - val jsCompiler: KotlinJsCompilerType? - get() = this.property(jsCompilerProperty)?.let { KotlinJsCompilerType.byArgumentOrNull(it) } - /** * Use Kotlin/JS backend compiler publishing attribute */ val publishJsCompilerAttribute: Boolean get() = this.booleanProperty("$jsCompilerProperty.publish.attribute") ?: true - /** - * Use Kotlin/JS backend compiler type - */ - val jsGenerateExecutableDefault: Boolean - get() = (booleanProperty("kotlin.js.generate.executable.default") ?: true).also { - KotlinBuildStatsService.getInstance() - ?.report(StringMetrics.JS_GENERATE_EXECUTABLE_DEFAULT, it.toString()) - } - val stdlibDefaultDependency: Boolean get() = booleanProperty(KOTLIN_STDLIB_DEFAULT_DEPENDENCY) ?: true diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/KotlinMultiplatformPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/KotlinMultiplatformPlugin.kt index b74d8f4d72e..7c1f5eec614 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/KotlinMultiplatformPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/KotlinMultiplatformPlugin.kt @@ -130,13 +130,7 @@ class KotlinMultiplatformPlugin : Plugin { fun setupDefaultPresets(project: Project) { with(project.multiplatformExtension.presets) { add(KotlinJvmTargetPreset(project)) - add(KotlinJsTargetPreset(project).apply { irPreset = null }) - add(KotlinJsIrTargetPreset(project).apply { mixedMode = false }) - add( - KotlinJsTargetPreset(project).apply { - irPreset = KotlinJsIrTargetPreset(project).apply { mixedMode = true } - } - ) + add(KotlinJsIrTargetPreset(project)) add(KotlinWasmTargetPreset(project)) add(project.objects.newInstance(KotlinAndroidTargetPreset::class.java, project)) add(KotlinJvmWithJavaTargetPreset(project)) diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/factory/KotlinCompilationDependencyConfigurationsFactories.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/factory/KotlinCompilationDependencyConfigurationsFactories.kt index 526a76816e4..8ad88bda6b5 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/factory/KotlinCompilationDependencyConfigurationsFactories.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/factory/KotlinCompilationDependencyConfigurationsFactories.kt @@ -15,7 +15,6 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.KotlinCompilationC import org.jetbrains.kotlin.gradle.plugin.mpp.javaSourceSets import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.copyAttributes import org.jetbrains.kotlin.gradle.plugin.sources.METADATA_CONFIGURATION_NAME_SUFFIX -import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget import org.jetbrains.kotlin.gradle.utils.* @@ -51,20 +50,6 @@ internal object NativeKotlinCompilationDependencyConfigurationsFactory : } } -internal object JsKotlinCompilationDependencyConfigurationsFactory : - KotlinCompilationImplFactory.KotlinCompilationDependencyConfigurationsFactory { - - override fun create(target: KotlinTarget, compilationName: String): KotlinCompilationConfigurationsContainer { - val defaultNaming = ConfigurationNaming.Default(target, compilationName) - return KotlinCompilationDependencyConfigurationsContainer( - target, compilationName, withRuntime = true, - naming = ConfigurationNaming.Js(target, compilationName), - compileClasspathConfigurationName = defaultNaming.name(compileClasspath), - runtimeClasspathConfigurationName = defaultNaming.name(runtimeClasspath) - ) - } -} - internal class JvmWithJavaCompilationDependencyConfigurationsFactory(private val target: KotlinWithJavaTarget<*, *>) : KotlinCompilationImplFactory.KotlinCompilationDependencyConfigurationsFactory { override fun create(target: KotlinTarget, compilationName: String): KotlinCompilationConfigurationsContainer { @@ -92,22 +77,6 @@ private fun interface ConfigurationNaming { target.disambiguationClassifier, compilationName.takeIf { it != KotlinCompilation.MAIN_COMPILATION_NAME }, *parts ) } - - class Js( - private val target: KotlinTarget, - private val compilationName: String - ) : ConfigurationNaming { - override fun name(vararg parts: String): String = lowerCamelCaseName( - target.disambiguationClassifierInPlatform, compilationName.takeIf { it != KotlinCompilation.MAIN_COMPILATION_NAME }, *parts - ) - - private val KotlinTarget.disambiguationClassifierInPlatform: String? - get() = when (this) { - is KotlinJsTarget -> disambiguationClassifierInPlatform - is KotlinJsIrTarget -> disambiguationClassifierInPlatform - else -> error("Unexpected target type of $this") - } - } } private const val compilation = "compilation" diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/factory/KotlinCompilationSourceSetsContainerFactories.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/factory/KotlinCompilationSourceSetsContainerFactories.kt index 50be528080f..c39e3b49699 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/factory/KotlinCompilationSourceSetsContainerFactories.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/factory/KotlinCompilationSourceSetsContainerFactories.kt @@ -14,8 +14,6 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.KotlinCompilationSourceSetsContainer import org.jetbrains.kotlin.gradle.plugin.sources.android.kotlinAndroidSourceSetLayout -import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget -import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName internal class DefaultKotlinCompilationSourceSetsContainerFactory( @@ -50,28 +48,4 @@ internal class AndroidCompilationSourceSetsContainerFactory( ?: lowerCamelCaseName(target.disambiguationClassifier, compilationName) return KotlinCompilationSourceSetsContainer(target.project.kotlinExtension.sourceSets.maybeCreate(sourceSetName)) } -} - -internal object JsCompilationSourceSetsContainerFactory : KotlinCompilationImplFactory.KotlinCompilationSourceSetsContainerFactory { - override fun create(target: KotlinTarget, compilationName: String): KotlinCompilationSourceSetsContainer { - val defaultSourceSetName = lowerCamelCaseName( - if (target is KotlinJsTarget && target.irTarget != null) target.disambiguationClassifierInPlatform - else target.disambiguationClassifier, - compilationName - ) - - return KotlinCompilationSourceSetsContainer(target.project.kotlinExtension.sourceSets.maybeCreate(defaultSourceSetName)) - } -} - -internal object JsIrCompilationSourceSetsContainerFactory : KotlinCompilationImplFactory.KotlinCompilationSourceSetsContainerFactory { - override fun create(target: KotlinTarget, compilationName: String): KotlinCompilationSourceSetsContainer { - val defaultSourceSetName = lowerCamelCaseName( - if (target is KotlinJsIrTarget && target.mixedMode) target.disambiguationClassifierInPlatform - else target.disambiguationClassifier, - compilationName - ) - - return KotlinCompilationSourceSetsContainer(target.project.kotlinExtension.sourceSets.maybeCreate(defaultSourceSetName)) - } -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/KotlinSourceSetFactory.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/KotlinSourceSetFactory.kt index 7e1a202c512..a3cbf2d273b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/KotlinSourceSetFactory.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/KotlinSourceSetFactory.kt @@ -7,17 +7,10 @@ package org.jetbrains.kotlin.gradle.plugin.sources import org.gradle.api.NamedDomainObjectFactory import org.gradle.api.Project -import org.gradle.api.artifacts.Configuration import org.gradle.api.attributes.Category import org.gradle.api.attributes.Usage -import org.jetbrains.kotlin.gradle.dsl.kotlinExtension import org.jetbrains.kotlin.gradle.plugin.* -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages -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.ir.KotlinJsIrTarget import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled import org.jetbrains.kotlin.gradle.utils.getOrCreate import java.io.File @@ -108,67 +101,10 @@ internal class DefaultKotlinSourceSetFactory( if (project.isKotlinGranularMetadataEnabled) { attributes.attribute(Usage.USAGE_ATTRIBUTE, project.usageByName(KotlinUsages.KOTLIN_METADATA)) } - - project.afterEvaluate { - setJsCompilerIfNecessary(sourceSet, this) - } } } } - // KT-47163 - // It is necessary to set jsCompilerAttribute to configurations which associated with ONLY js source sets - // Otherwise configuration cannot be resolved because ambiguity between IR and Legacy variants inside one module - private val notOnlyJsSourceSets = mutableSetOf() - - private val jsOnlySourceSetsAttributes = mutableMapOf() - - private fun setJsCompilerIfNecessary(sourceSet: KotlinSourceSet, configuration: Configuration) { - if (sourceSet in notOnlyJsSourceSets) return - - if (sourceSet in jsOnlySourceSetsAttributes) { - configuration.attributes.attribute( - KotlinJsCompilerAttribute.jsCompilerAttribute, - jsOnlySourceSetsAttributes.getValue(sourceSet) - ) - return - } - - project.kotlinExtension.targets - .filter { it !is KotlinJsIrTarget && it !is KotlinJsTarget } - .forEach { target -> - target.compilations.forEach { compilation -> - notOnlyJsSourceSets.addAll(compilation.allKotlinSourceSets) - } - } - - if (sourceSet in notOnlyJsSourceSets) return - - fun chooseCompilerAttribute(target: KotlinTarget): KotlinJsCompilerAttribute { - if (target is KotlinJsIrTarget) { - return KotlinJsCompilerAttribute.ir - } - - target as KotlinJsTarget - return if (target.irTarget != null) KotlinJsCompilerAttribute.ir else KotlinJsCompilerAttribute.legacy - } - - project.kotlinExtension.targets - .filter { it is KotlinJsTarget || (it is KotlinJsIrTarget && it.platformType == KotlinPlatformType.js) } - .forEach { target -> - target.compilations - .filterIsInstance() - .forEach { compilation -> - if (sourceSet in compilation.allKotlinSourceSets) { - val compilerAttribute = chooseCompilerAttribute(target) - jsOnlySourceSetsAttributes[sourceSet] = compilerAttribute - configuration.attributes.attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, compilerAttribute) - return - } - } - } - } - override fun doCreateSourceSet(name: String): DefaultKotlinSourceSet = project.objects.newInstance(DefaultKotlinSourceSet::class.java, project, name) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsCompilationFactory.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsCompilationFactory.kt index 61aac6fff82..8974cb1ca11 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsCompilationFactory.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsCompilationFactory.kt @@ -6,24 +6,7 @@ @file:Suppress("PackageDirectoryMismatch") // Old package for compatibility package org.jetbrains.kotlin.gradle.plugin.mpp -import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.factory.JsCompilationSourceSetsContainerFactory -import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.factory.JsKotlinCompilationDependencyConfigurationsFactory -import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.factory.KotlinCompilationImplFactory -import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.factory.KotlinJsCompilerOptionsFactory +import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrCompilationFactory -class KotlinJsCompilationFactory internal constructor( - override val target: KotlinOnlyTarget -) : KotlinCompilationFactory { - override val itemClass: Class - get() = KotlinJsCompilation::class.java - - private val compilationImplFactory: KotlinCompilationImplFactory = KotlinCompilationImplFactory( - compilerOptionsFactory = KotlinJsCompilerOptionsFactory, - compilationSourceSetsContainerFactory = JsCompilationSourceSetsContainerFactory, - compilationDependencyConfigurationsFactory = JsKotlinCompilationDependencyConfigurationsFactory - ) - - override fun create(name: String): KotlinJsCompilation = target.project.objects.newInstance( - itemClass, compilationImplFactory.create(target, name) - ) -} +@Deprecated("The Kotlin/JS legacy target is deprecated and its support completely discontinued") +typealias KotlinJsCompilationFactory = KotlinJsIrCompilationFactory \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsPlugin.kt index 85892b9ee38..b65b53ec02b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsPlugin.kt @@ -13,8 +13,6 @@ import org.jetbrains.kotlin.gradle.dsl.kotlinExtension import org.jetbrains.kotlin.gradle.internal.customizeKotlinDependencies import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.TEST_COMPILATION_NAME -import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsSingleTargetPreset import org.jetbrains.kotlin.gradle.plugin.mpp.setupGeneralKotlinExtensionParameters import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrSingleTargetPreset import org.jetbrains.kotlin.gradle.utils.* @@ -38,7 +36,6 @@ open class KotlinJsPlugin: Plugin { kotlinExtension.apply { irPreset = KotlinJsIrSingleTargetPreset(project) - legacyPreset = KotlinJsSingleTargetPreset(project) } project.runProjectConfigurationHealthCheckWhenEvaluated { diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTarget.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTarget.kt index 8b2738914ed..2c77a6c1b36 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTarget.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTarget.kt @@ -5,248 +5,11 @@ package org.jetbrains.kotlin.gradle.targets.js -import org.gradle.api.NamedDomainObjectContainer -import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.tasks.TaskProvider -import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension -import org.jetbrains.kotlin.gradle.dsl.kotlinExtension -import org.jetbrains.kotlin.gradle.plugin.* -import org.jetbrains.kotlin.gradle.plugin.AbstractKotlinTargetConfigurator.Companion.runTaskNameSuffix -import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.LEGACY -import org.jetbrains.kotlin.gradle.plugin.mpp.* -import org.jetbrains.kotlin.gradle.plugin.mpp.PRIMARY_SINGLE_COMPONENT_NAME -import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBrowserDsl -import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsNodeDsl -import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsSubTargetContainerDsl -import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl -import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsBinaryContainer -import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget -import org.jetbrains.kotlin.gradle.targets.js.npm.NpmResolverPlugin -import org.jetbrains.kotlin.gradle.targets.js.subtargets.KotlinBrowserJs -import org.jetbrains.kotlin.gradle.targets.js.subtargets.KotlinNodeJs -import org.jetbrains.kotlin.gradle.tasks.locateOrRegisterTask -import org.jetbrains.kotlin.gradle.tasks.locateTask -import org.jetbrains.kotlin.gradle.testing.internal.KotlinTestReport -import org.jetbrains.kotlin.gradle.testing.testTaskName -import org.jetbrains.kotlin.gradle.utils.dashSeparatedName -import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName -import org.jetbrains.kotlin.gradle.utils.setProperty -import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly -import org.jetbrains.kotlin.utils.addIfNotNull -import javax.inject.Inject +import org.jetbrains.kotlin.gradle.plugin.KotlinTarget +import org.jetbrains.kotlin.gradle.plugin.mpp.InternalKotlinTarget -abstract class KotlinJsTarget -@Inject -constructor( - project: Project, - platformType: KotlinPlatformType -) : - KotlinTargetWithBinaries(project, platformType), - KotlinTargetWithTests, - KotlinJsTargetDsl, - KotlinJsSubTargetContainerDsl { - override lateinit var testRuns: NamedDomainObjectContainer - internal set - - override var moduleName: String? = null - set(value) { - check(!isBrowserConfigured && !isNodejsConfigured) { - "Please set moduleName before initialize browser() or nodejs()" - } - field = value - } - - internal val commonFakeApiElementsConfigurationName: String - get() = lowerCamelCaseName( - irTarget?.let { - this.disambiguationClassifierInPlatform - } ?: disambiguationClassifier, - "commonFakeApiElements" - ) - - val disambiguationClassifierInPlatform: String? - get() = if (irTarget != null) { - disambiguationClassifier?.removeJsCompilerSuffix(LEGACY) - } else { - disambiguationClassifier - } - - override val kotlinComponents: Set by lazy { - if (irTarget == null) - super.kotlinComponents - else { - val mainCompilation = compilations.getByName(MAIN_COMPILATION_NAME) - val usageContexts = createUsageContexts(mainCompilation).toMutableSet() - - usageContexts += irTarget!!.createUsageContexts(irTarget!!.compilations.getByName(MAIN_COMPILATION_NAME)) - - val componentName = - if (project.kotlinExtension is KotlinMultiplatformExtension) - irTarget?.let { targetName.removeJsCompilerSuffix(LEGACY) } ?: targetName - else PRIMARY_SINGLE_COMPONENT_NAME - - usageContexts.addIfNotNull( - createSourcesJarAndUsageContextIfPublishable( - mainCompilation, - componentName, - dashSeparatedName(targetName.toLowerCaseAsciiOnly()), - mavenScope = KotlinUsageContext.MavenScope.RUNTIME - ) - ) - - val result = createKotlinVariant(componentName, mainCompilation, usageContexts) - - setOf(result) - } - } - - override fun createUsageContexts(producingCompilation: KotlinCompilation<*>): Set { - val usageContexts = super.createUsageContexts(producingCompilation) - - if (isMpp!!) return usageContexts - - return usageContexts + - DefaultKotlinUsageContext( - compilation = compilations.getByName(MAIN_COMPILATION_NAME), - mavenScope = KotlinUsageContext.MavenScope.COMPILE, - dependencyConfigurationName = commonFakeApiElementsConfigurationName, - overrideConfigurationArtifacts = project.setProperty { emptyList() } - ) - } - - override fun createKotlinVariant( - componentName: String, - compilation: KotlinCompilation<*>, - usageContexts: Set - ): KotlinVariant { - return super.createKotlinVariant(componentName, compilation, usageContexts).apply { - irTarget?.let { - artifactTargetName = targetName.removeJsCompilerSuffix(LEGACY) - } - } - } - - override val binaries: KotlinJsBinaryContainer - get() = compilations.withType(KotlinJsCompilation::class.java) - .named(MAIN_COMPILATION_NAME) - .map { it.binaries } - .get() - - var irTarget: KotlinJsIrTarget? = null - internal set - - open var isMpp: Boolean? = null - internal set - - val testTaskName get() = testRuns.getByName(KotlinTargetWithTests.DEFAULT_TEST_RUN_NAME).testTaskName - val testTask: TaskProvider - get() = checkNotNull(project.locateTask(testTaskName)) - - val runTaskName get() = lowerCamelCaseName(disambiguationClassifier, runTaskNameSuffix) - val runTask: TaskProvider - get() = project.locateOrRegisterTask(runTaskName) { - it.description = "Run js on all configured platforms" - } - - private val propertiesProvider = PropertiesProvider(project) - - private val commonLazy by lazy { - NpmResolverPlugin.apply(project) - } - - //Browser - private val browserLazyDelegate = lazy { - commonLazy - project.objects.newInstance(KotlinBrowserJs::class.java, this).also { - it.configure() - - if (propertiesProvider.jsGenerateExecutableDefault && irTarget == null) { - binaries.executable() - } - - browserConfiguredHandlers.forEach { handler -> - handler(it) - } - browserConfiguredHandlers.clear() - } - } - - private val browserConfiguredHandlers = mutableListOf Unit>() - - override val browser by browserLazyDelegate - - override val isBrowserConfigured: Boolean - get() = browserLazyDelegate.isInitialized() - - override fun browser(body: KotlinJsBrowserDsl.() -> Unit) { - body(browser) - irTarget?.browser(body) - } - - //node.js - private val nodejsLazyDelegate = lazy { - commonLazy - project.objects.newInstance(KotlinNodeJs::class.java, this).also { - it.configure() - - if (propertiesProvider.jsGenerateExecutableDefault && irTarget == null) { - binaries.executable() - } - - nodejsConfiguredHandlers.forEach { handler -> - handler(it) - } - - nodejsConfiguredHandlers.clear() - } - } - - private val nodejsConfiguredHandlers = mutableListOf Unit>() - - override val nodejs by nodejsLazyDelegate - - override val isNodejsConfigured: Boolean - get() = nodejsLazyDelegate.isInitialized() - - override fun nodejs(body: KotlinJsNodeDsl.() -> Unit) { - body(nodejs) - irTarget?.nodejs(body) - } - - override fun whenBrowserConfigured(body: KotlinJsBrowserDsl.() -> Unit) { - if (browserLazyDelegate.isInitialized()) { - browser(body) - } else { - browserConfiguredHandlers += body - } - } - - override fun whenNodejsConfigured(body: KotlinJsNodeDsl.() -> Unit) { - if (nodejsLazyDelegate.isInitialized()) { - nodejs(body) - } else { - nodejsConfiguredHandlers += body - } - } - - override fun useCommonJs() { - compilations.all { - it.kotlinOptions { - moduleKind = "commonjs" - sourceMap = true - sourceMapEmbedSources = null - } - } - irTarget?.useCommonJs() - } - - override fun useEsModules() { - error("ES modules are not supported in legacy JS compiler. Please, use IR one instead.") - } - - override fun generateTypeScriptDefinitions() { - project.logger.warn("Legacy compiler does not support generation of TypeScript Definitions") - } +@Deprecated("The Kotlin/JS legacy target is deprecated and its support completely discontinued", level = DeprecationLevel.WARNING) +abstract class KotlinJsTarget : KotlinTarget, InternalKotlinTarget { + @Deprecated("Only for compatibility") + val irTarget = null } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargetConfigurator.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargetConfigurator.kt index cc7e64bbde4..941eb52b8bd 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargetConfigurator.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargetConfigurator.kt @@ -5,123 +5,7 @@ package org.jetbrains.kotlin.gradle.targets.js -import org.gradle.api.DefaultTask -import org.gradle.api.Task -import org.gradle.api.attributes.Usage -import org.gradle.language.base.plugins.LifecycleBasePlugin -import org.jetbrains.kotlin.gradle.plugin.* -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages -import org.jetbrains.kotlin.gradle.plugin.mpp.addSourceSet -import org.jetbrains.kotlin.gradle.tasks.KotlinTasksProvider -import org.jetbrains.kotlin.gradle.tasks.locateTask -import org.jetbrains.kotlin.gradle.tasks.registerTask -import org.jetbrains.kotlin.gradle.testing.internal.kotlinTestRegistry -import org.jetbrains.kotlin.gradle.testing.testTaskName -import java.util.concurrent.Callable +import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTargetConfigurator -open class KotlinJsTargetConfigurator : - KotlinOnlyTargetConfigurator(true), - KotlinTargetWithTestsConfigurator { - - override val testRunClass: Class get() = KotlinJsReportAggregatingTestRun::class.java - - override fun createTestRun( - name: String, - target: KotlinJsTarget - ): KotlinJsReportAggregatingTestRun { - val result = target.project.objects.newInstance( - KotlinJsReportAggregatingTestRun::class.java, - name, - target - ) - - val testTask = target.project.kotlinTestRegistry.getOrCreateAggregatedTestTask( - name = result.testTaskName, - description = "Run JS tests for all platforms" - ) - - // workaround to avoid the infinite recursion in item factories of the target and the subtargets: - target.testRuns.matching { it.name == name }.whenObjectAdded { - it.configureAllExecutions { - // do not do anything with the aggregated test run, but ensure that they are created - } - } - - result.executionTask = testTask - - return result - } - - override fun buildCompilationProcessor(compilation: KotlinJsCompilation): KotlinSourceSetProcessor<*> { - val tasksProvider = KotlinTasksProvider() - return Kotlin2JsSourceSetProcessor(tasksProvider, KotlinCompilationInfo(compilation)) - } - - override fun configureCompilationDefaults(target: KotlinJsTarget) { - val project = target.project - - target.compilations.all { compilation -> - @Suppress("DEPRECATION") - compilation.addSourceSet(compilation.defaultSourceSet) - - configureResourceProcessing( - compilation, - compilation.processResourcesTaskName, - project.files(Callable { compilation.allKotlinSourceSets.map { it.resources } }) - ) - - createLifecycleTaskInternal(compilation) - } - } - - private fun createLifecycleTaskInternal(compilation: KotlinJsCompilation) { - val project = compilation.target.project - - compilation.output.classesDirs.from(project.files().builtBy(compilation.compileAllTaskName)) - - val compileAllTask = project.locateTask(compilation.compileAllTaskName) - if (compileAllTask != null) { - compileAllTask.configure { - it.dependsOn(compilation.compileKotlinTaskName) - it.dependsOn(compilation.processResourcesTaskName) - } - } else { - project.registerTask(compilation.compileAllTaskName) { - it.group = LifecycleBasePlugin.BUILD_GROUP - it.description = "Assembles outputs for compilation '${compilation.name}' of target '${compilation.target.name}'" - it.dependsOn(compilation.compileKotlinTaskName) - it.dependsOn(compilation.processResourcesTaskName) - } - } - } - - override fun configureCompilations(target: KotlinJsTarget) { - super.configureCompilations(target) - - target.compilations.all { - it.kotlinOptions { - moduleKind = "umd" - sourceMap = true - sourceMapEmbedSources = null - } - } - } - - override fun defineConfigurationsForTarget(target: KotlinJsTarget) { - super.defineConfigurationsForTarget(target) - - if (target.isMpp!!) return - - target.project.configurations.maybeCreate( - target.commonFakeApiElementsConfigurationName - ).apply { - description = "Common Fake API elements for main." - isVisible = false - isCanBeResolved = false - isCanBeConsumed = true - attributes.attribute(Usage.USAGE_ATTRIBUTE, KotlinUsages.producerApiUsage(target)) - attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.common) - } - } -} \ No newline at end of file +@Deprecated("The Kotlin/JS legacy target is deprecated and its support completely discontinued") +typealias KotlinJsTargetConfigurator = KotlinJsIrTargetConfigurator \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargetPreset.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargetPreset.kt index 3e2a7676b32..69bbb62d861 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargetPreset.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargetPreset.kt @@ -9,102 +9,18 @@ package org.jetbrains.kotlin.gradle.plugin.mpp import org.gradle.api.Project -import org.jetbrains.kotlin.gradle.plugin.* -import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService -import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget -import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTargetConfigurator -import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTargetPreset -import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName -import org.jetbrains.kotlin.gradle.utils.runProjectConfigurationHealthCheckWhenEvaluated -import org.jetbrains.kotlin.statistics.metrics.StringMetrics -import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeAsciiOnly -open class KotlinJsTargetPreset( +@Deprecated("The Kotlin/JS legacy target is deprecated and its support completely discontinued", level = DeprecationLevel.WARNING) +abstract class KotlinJsTargetPreset( project: Project -) : KotlinOnlyTargetPreset( +) : KotlinOnlyTargetPreset, KotlinJsCompilation>( project -) { - var irPreset: KotlinJsIrTargetPreset? = null - internal set +) - open val isMpp: Boolean - get() = true - - override val platformType: KotlinPlatformType - get() = KotlinPlatformType.js - - override fun useDisambiguationClassifierAsSourceSetNamePrefix() = irPreset == null - - override fun overrideDisambiguationClassifierOnIdeImport(name: String): String? = - irPreset?.let { - name.removeJsCompilerSuffix(KotlinJsCompilerType.LEGACY) - } - - override fun instantiateTarget(name: String): KotlinJsTarget { - return project.objects.newInstance( - KotlinJsTarget::class.java, - project, - platformType - ).apply { - this.irTarget = irPreset?.createTarget( - lowerCamelCaseName( - name.removeJsCompilerSuffix(KotlinJsCompilerType.LEGACY), - KotlinJsCompilerType.IR.lowerName - ) - )?.also { - it.legacyTarget = this - } - this.isMpp = this@KotlinJsTargetPreset.isMpp - - project.runProjectConfigurationHealthCheckWhenEvaluated { - val buildStatsService = KotlinBuildStatsService.getInstance() - when { - isBrowserConfigured && isNodejsConfigured -> buildStatsService?.report(StringMetrics.JS_TARGET_MODE, "both") - isBrowserConfigured -> buildStatsService?.report(StringMetrics.JS_TARGET_MODE, "browser") - isNodejsConfigured -> buildStatsService?.report(StringMetrics.JS_TARGET_MODE, "nodejs") - !isBrowserConfigured && !isNodejsConfigured -> buildStatsService?.report(StringMetrics.JS_TARGET_MODE, "none") - } - Unit - } - } - } - - override fun createKotlinTargetConfigurator() = KotlinJsTargetConfigurator() - - override fun getName(): String { - return lowerCamelCaseName( - PRESET_NAME, - irPreset?.let { KotlinJsCompilerType.BOTH.lowerName } - ) - } - - override fun createCompilationFactory(forTarget: KotlinJsTarget): KotlinJsCompilationFactory { - return KotlinJsCompilationFactory(forTarget) - } - - companion object { - const val PRESET_NAME = "js" - } -} - -class KotlinJsSingleTargetPreset( +@Suppress("DEPRECATION") +@Deprecated("The Kotlin/JS legacy target is deprecated and its support completely discontinued", level = DeprecationLevel.HIDDEN) +abstract class KotlinJsSingleTargetPreset( project: Project ) : KotlinJsTargetPreset( project -) { - override val isMpp: Boolean - get() = false - - override fun overrideDisambiguationClassifierOnIdeImport(name: String): String? = - null - - // In a Kotlin/JS single-platform project, we don't need any disambiguation suffixes or prefixes in the names: - override fun provideTargetDisambiguationClassifier(target: KotlinOnlyTarget): String? = - irPreset?.let { - super.provideTargetDisambiguationClassifier(target) - ?.removePrefix(target.name.removeJsCompilerSuffix(KotlinJsCompilerType.LEGACY)) - ?.decapitalizeAsciiOnly() - } - - override fun createKotlinTargetConfigurator() = KotlinJsTargetConfigurator() -} +) diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargets.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargets.kt deleted file mode 100644 index d984bd7b9e5..00000000000 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargets.kt +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2010-2020 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.gradle.targets.js - -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType -import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl -import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget - -fun KotlinJsTargetDsl.calculateJsCompilerType(): KotlinJsCompilerType { - return when { - this is KotlinJsTarget && this.irTarget == null -> KotlinJsCompilerType.LEGACY - this is KotlinJsIrTarget && !this.mixedMode -> KotlinJsCompilerType.IR - this is KotlinJsTarget && this.irTarget != null -> KotlinJsCompilerType.BOTH - else -> throw IllegalStateException("Unable to find previous Kotlin/JS compiler type for $this") - } -} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsBinaryContainer.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsBinaryContainer.kt index a8697e0318e..3267e58ea04 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsBinaryContainer.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsBinaryContainer.kt @@ -14,14 +14,11 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinTargetWithBinaries import org.jetbrains.kotlin.gradle.plugin.mpp.isMain -import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget import org.jetbrains.kotlin.gradle.targets.js.binaryen.BinaryenExec import org.jetbrains.kotlin.gradle.targets.js.dsl.Distribution import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBinaryMode import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBinaryMode.DEVELOPMENT import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBinaryMode.PRODUCTION -import org.jetbrains.kotlin.gradle.targets.js.subtargets.DefaultDistribution -import org.jetbrains.kotlin.gradle.targets.js.subtargets.KotlinJsSubTarget import org.jetbrains.kotlin.gradle.targets.js.subtargets.createDefaultDistribution import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly @@ -82,22 +79,7 @@ constructor( return compilation.binaries.executableIrInternal(compilation) } - if (target is KotlinJsTarget) { - target.irTarget - ?.let { throw IllegalStateException("Can't use `executable()` with 'both' compiler type") } - - target.whenBrowserConfigured { - (this as KotlinJsSubTarget).produceExecutable() - } - - target.whenNodejsConfigured { - (this as KotlinJsSubTarget).produceExecutable() - } - - return compilation.binaries.executableLegacyInternal(compilation) - } - - throw GradleException("Target should be either KotlinJsTarget or KotlinJsIrTarget, but found $target") + throw GradleException("Target should be KotlinJsIrTarget, but found $target") } internal fun executableIrInternal(compilation: KotlinJsCompilation): List = createBinaries( diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrCompilationFactory.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrCompilationFactory.kt index a6b4e34ab85..a686a061a69 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrCompilationFactory.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrCompilationFactory.kt @@ -8,8 +8,6 @@ package org.jetbrains.kotlin.gradle.targets.js.ir import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinCompilationFactory import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinOnlyTarget import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.DefaultKotlinCompilationFriendPathsResolver -import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.factory.JsIrCompilationSourceSetsContainerFactory -import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.factory.JsKotlinCompilationDependencyConfigurationsFactory import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.factory.KotlinCompilationImplFactory import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.factory.KotlinJsCompilerOptionsFactory @@ -22,12 +20,10 @@ class KotlinJsIrCompilationFactory internal constructor( private val compilationImplFactory: KotlinCompilationImplFactory = KotlinCompilationImplFactory( compilerOptionsFactory = KotlinJsCompilerOptionsFactory, compilationFriendPathsResolver = DefaultKotlinCompilationFriendPathsResolver( - friendArtifactResolver = DefaultKotlinCompilationFriendPathsResolver.FriendArtifactResolver { _ -> + friendArtifactResolver = { _ -> target.project.files() } ), - compilationSourceSetsContainerFactory = JsIrCompilationSourceSetsContainerFactory, - compilationDependencyConfigurationsFactory = JsKotlinCompilationDependencyConfigurationsFactory ) override fun create(name: String): KotlinJsIrCompilation = target.project.objects.newInstance( diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTarget.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTarget.kt index 3d90deea5c0..3dc86098fe1 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTarget.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTarget.kt @@ -10,15 +10,17 @@ import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.tasks.TaskProvider import org.jetbrains.kotlin.gradle.dsl.KotlinJsOptions -import org.jetbrains.kotlin.gradle.plugin.* import org.jetbrains.kotlin.gradle.plugin.AbstractKotlinTargetConfigurator.Companion.runTaskNameSuffix +import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME +import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType +import org.jetbrains.kotlin.gradle.plugin.KotlinTargetWithTests +import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider import org.jetbrains.kotlin.gradle.plugin.mpp.DefaultKotlinUsageContext import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinTargetWithBinaries import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsageContext import org.jetbrains.kotlin.gradle.targets.js.JsAggregatingExecutionSource import org.jetbrains.kotlin.gradle.targets.js.KotlinJsReportAggregatingTestRun -import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget import org.jetbrains.kotlin.gradle.targets.js.binaryen.BinaryenExec import org.jetbrains.kotlin.gradle.targets.js.dsl.* import org.jetbrains.kotlin.gradle.targets.js.npm.NpmResolverPlugin @@ -35,7 +37,6 @@ abstract class KotlinJsIrTarget constructor( project: Project, platformType: KotlinPlatformType, - internal val mixedMode: Boolean ) : KotlinTargetWithBinaries(project, platformType), KotlinTargetWithTests, @@ -50,9 +51,6 @@ constructor( open var isMpp: Boolean? = null internal set - var legacyTarget: KotlinJsTarget? = null - internal set - override var moduleName: String? = null set(value) { check(!isBrowserConfigured && !isNodejsConfigured) { @@ -64,7 +62,7 @@ constructor( override fun createUsageContexts(producingCompilation: KotlinCompilation<*>): Set { val usageContexts = super.createUsageContexts(producingCompilation) - if (isMpp!! || mixedMode) return usageContexts + if (isMpp!!) return usageContexts return usageContexts + DefaultKotlinUsageContext( @@ -77,20 +75,10 @@ constructor( internal val commonFakeApiElementsConfigurationName: String get() = lowerCamelCaseName( - if (mixedMode) - disambiguationClassifierInPlatform - else - disambiguationClassifier, + disambiguationClassifier, "commonFakeApiElements" ) - val disambiguationClassifierInPlatform: String? - get() = if (mixedMode) { - disambiguationClassifier?.removeJsCompilerSuffix(KotlinJsCompilerType.IR) - } else { - disambiguationClassifier - } - override val binaries: KotlinJsBinaryContainer get() = compilations.withType(KotlinJsIrCompilation::class.java) .named(MAIN_COMPILATION_NAME) diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetPreset.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetPreset.kt index e69fb249ffa..6471cac7682 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetPreset.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetPreset.kt @@ -6,42 +6,39 @@ package org.jetbrains.kotlin.gradle.targets.js.ir import org.gradle.api.Project -import org.jetbrains.kotlin.gradle.plugin.* +import org.jetbrains.kotlin.gradle.plugin.AbstractKotlinTargetConfigurator +import org.jetbrains.kotlin.gradle.plugin.KotlinOnlyTargetConfigurator +import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinCompilationFactory import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinOnlyTarget import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinOnlyTargetPreset import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService -import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName import org.jetbrains.kotlin.gradle.utils.runProjectConfigurationHealthCheckWhenEvaluated import org.jetbrains.kotlin.statistics.metrics.StringMetrics -import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeAsciiOnly open class KotlinJsIrTargetPreset( - project: Project + project: Project, ) : KotlinOnlyTargetPreset( project ) { - internal var mixedMode: Boolean? = null - open val isMpp: Boolean get() = true override val platformType: KotlinPlatformType = KotlinPlatformType.js override fun instantiateTarget(name: String): KotlinJsIrTarget { - return project.objects.newInstance(KotlinJsIrTarget::class.java, project, platformType, mixedMode).apply { + return project.objects.newInstance(KotlinJsIrTarget::class.java, project, platformType).apply { this.isMpp = this@KotlinJsIrTargetPreset.isMpp - if (!mixedMode) { - project.runProjectConfigurationHealthCheckWhenEvaluated { - val buildStatsService = KotlinBuildStatsService.getInstance() - when { - isBrowserConfigured && isNodejsConfigured -> buildStatsService?.report(StringMetrics.JS_TARGET_MODE, "both") - isBrowserConfigured -> buildStatsService?.report(StringMetrics.JS_TARGET_MODE, "browser") - isNodejsConfigured -> buildStatsService?.report(StringMetrics.JS_TARGET_MODE, "nodejs") - !isBrowserConfigured && !isNodejsConfigured -> buildStatsService?.report(StringMetrics.JS_TARGET_MODE, "none") - } - Unit + project.runProjectConfigurationHealthCheckWhenEvaluated { + + val buildStatsService = KotlinBuildStatsService.getInstance() + when { + isBrowserConfigured && isNodejsConfigured -> buildStatsService?.report(StringMetrics.JS_TARGET_MODE, "both") + isBrowserConfigured -> buildStatsService?.report(StringMetrics.JS_TARGET_MODE, "browser") + isNodejsConfigured -> buildStatsService?.report(StringMetrics.JS_TARGET_MODE, "nodejs") + !isBrowserConfigured && !isNodejsConfigured -> buildStatsService?.report(StringMetrics.JS_TARGET_MODE, "none") } + Unit } } } @@ -53,20 +50,17 @@ open class KotlinJsIrTargetPreset( //TODO[Ilya Goncharov] remove public morozov public override fun createCompilationFactory( - forTarget: KotlinJsIrTarget + forTarget: KotlinJsIrTarget, ): KotlinCompilationFactory = KotlinJsIrCompilationFactory(forTarget) companion object { - val JS_PRESET_NAME = lowerCamelCaseName( - "js", - KotlinJsCompilerType.IR.lowerName - ) + val JS_PRESET_NAME = "js" } } class KotlinJsIrSingleTargetPreset( - project: Project + project: Project, ) : KotlinJsIrTargetPreset( project ) { @@ -75,13 +69,7 @@ class KotlinJsIrSingleTargetPreset( // In a Kotlin/JS single-platform project, we don't need any disambiguation suffixes or prefixes in the names: override fun provideTargetDisambiguationClassifier(target: KotlinOnlyTarget): String? { - return if (mixedMode!!) { - super.provideTargetDisambiguationClassifier(target) - ?.removePrefix(target.name.removeJsCompilerSuffix(KotlinJsCompilerType.IR)) - ?.decapitalizeAsciiOnly() - } else { - null - } + return null } override fun createKotlinTargetConfigurator(): KotlinOnlyTargetConfigurator = diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinWasmTargetPreset.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinWasmTargetPreset.kt index 8582709cf71..840e95ae095 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinWasmTargetPreset.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinWasmTargetPreset.kt @@ -24,7 +24,7 @@ class KotlinWasmTargetPreset( project.logger.warn("New 'wasm' target is Work-in-Progress and is subject to change without notice.") } - val irTarget = project.objects.newInstance(KotlinJsIrTarget::class.java, project, KotlinPlatformType.wasm, false) + val irTarget = project.objects.newInstance(KotlinJsIrTarget::class.java, project, KotlinPlatformType.wasm) irTarget.isMpp = true return irTarget diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt index c3d980e76fc..4af636bd6e6 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt @@ -14,7 +14,6 @@ import org.jetbrains.kotlin.gradle.dsl.kotlinExtensionOrNull import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType import org.jetbrains.kotlin.gradle.plugin.KotlinTarget import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation -import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget import org.jetbrains.kotlin.gradle.targets.js.npm.KotlinNpmResolutionManager import org.jetbrains.kotlin.gradle.targets.js.npm.resolved.KotlinProjectNpmResolution import java.io.Serializable @@ -73,15 +72,6 @@ class KotlinProjectNpmResolver( addCompilation(compilation) } } - - // Hack for mixed mode, when target is JS and contain JS-IR - if (target is KotlinJsTarget) { - target.irTarget?.compilations?.all { compilation -> - if (compilation is KotlinJsCompilation) { - addCompilation(compilation) - } - } - } } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/subtargets/KotlinBrowserJs.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/subtargets/KotlinBrowserJs.kt index e8042d3e7a8..3f3adb6a936 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/subtargets/KotlinBrowserJs.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/subtargets/KotlinBrowserJs.kt @@ -5,386 +5,10 @@ package org.jetbrains.kotlin.gradle.targets.js.subtargets -import org.gradle.api.Action -import org.gradle.api.Task -import org.gradle.api.provider.Property -import org.gradle.api.tasks.Copy -import org.gradle.api.tasks.TaskProvider -import org.gradle.language.base.plugins.LifecycleBasePlugin -import org.jetbrains.kotlin.gradle.dsl.KotlinJsDce -import org.jetbrains.kotlin.gradle.plugin.COMPILER_CLASSPATH_CONFIGURATION_NAME -import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation -import org.jetbrains.kotlin.gradle.plugin.mpp.isMain -import org.jetbrains.kotlin.gradle.plugin.mpp.isTest -import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.archivesName -import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.distsDirectory -import org.jetbrains.kotlin.gradle.report.BuildMetricsService -import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget -import org.jetbrains.kotlin.gradle.targets.js.dsl.* -import org.jetbrains.kotlin.gradle.targets.js.ir.executeTaskBaseName -import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension -import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin.Companion.kotlinNodeJsExtension -import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject -import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest -import org.jetbrains.kotlin.gradle.targets.js.testing.karma.KotlinKarma -import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack -import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig -import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig.Mode -import org.jetbrains.kotlin.gradle.targets.js.webpack.WebpackDevtool -import org.jetbrains.kotlin.gradle.tasks.dependsOn -import org.jetbrains.kotlin.gradle.tasks.registerTask -import org.jetbrains.kotlin.gradle.utils.doNotTrackStateCompat -import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName -import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly -import java.io.File -import javax.inject.Inject -import org.jetbrains.kotlin.gradle.tasks.KotlinJsDce as KotlinJsDceTask +import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBrowserDsl -abstract class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) : - KotlinJsSubTarget(target, "browser"), - KotlinJsBrowserDsl { - - private val webpackTaskConfigurations: MutableList> = mutableListOf() - private val runTaskConfigurations: MutableList> = mutableListOf() - private val dceConfigurations: MutableList> = mutableListOf() - private val distribution: Distribution = createDefaultDistribution(project, target.targetName) - - override val testTaskDescription: String - get() = "Run all ${target.name} tests inside browser using karma and webpack" - - override fun configureDefaultTestFramework(testTask: KotlinJsTest) { - testTask.useKarma { - useChromeHeadless() - } - } - - override fun commonWebpackConfig(body: Action) { - webpackTaskConfigurations.add { - it.webpackConfigApplier(body) - } - runTaskConfigurations.add { - it.webpackConfigApplier(body) - } - testTask(Action { - it.onTestFrameworkSet { - if (it is KotlinKarma) { - body.execute(it.webpackConfig) - } - } - }) - } - - override fun runTask(body: Action) { - runTaskConfigurations.add(body) - } - - @ExperimentalDistributionDsl - override fun distribution(body: Action) { - body.execute(distribution) - } - - override fun webpackTask(body: Action) { - webpackTaskConfigurations.add(body) - } - - @ExperimentalDceDsl - override fun dceTask(body: Action) { - dceConfigurations.add(body) - } - - override fun configureMain(compilation: KotlinJsCompilation) { - val (dceTaskProvider, devDceTaskProvider) = compilation.configureDceTasks() - - // Adding dce tasks to additional JS compilations - target.compilations.configureEach { - if (!it.isMain() && !it.isTest()) it.configureDceTasks() - } - - configureRun( - compilation = compilation, - dceTaskProvider = dceTaskProvider, - devDceTaskProvider = devDceTaskProvider - ) - configureBuild( - compilation = compilation, - dceTaskProvider = dceTaskProvider, - devDceTaskProvider = devDceTaskProvider - ) - } - - private fun KotlinJsCompilation.configureDceTasks(): Pair, TaskProvider> { - val dceTaskProvider = configureDce( - compilation = this, - dev = false - ) - - val devDceTaskProvider = configureDce( - compilation = this, - dev = true - ) - - return dceTaskProvider to devDceTaskProvider - } - - private fun configureRun( - compilation: KotlinJsCompilation, - dceTaskProvider: TaskProvider, - devDceTaskProvider: TaskProvider - ) { - val project = compilation.target.project - val nodeJs = project.rootProject.kotlinNodeJsExtension - - val commonRunTask = registerSubTargetTask(disambiguateCamelCased(RUN_TASK_NAME)) {} - - compilation.binaries - .all { binary -> - val type = binary.mode - val distsDirectory = project.distsDirectory - val archivesName = project.archivesName - - val runTask = registerSubTargetTask( - disambiguateCamelCased( - binary.executeTaskBaseName, - RUN_TASK_NAME - ), - listOf(compilation) - ) { task -> - task.outputDirectory.convention(distsDirectory).finalizeValueOnRead() - task.args.add(0, "serve") - - task.description = "start ${type.name.toLowerCaseAsciiOnly()} webpack dev server" - - task.devServer = KotlinWebpackConfig.DevServer( - open = true, - static = mutableListOf(compilation.output.resourcesDir.canonicalPath), - client = KotlinWebpackConfig.DevServer.Client( - KotlinWebpackConfig.DevServer.Client.Overlay( - errors = true, - warnings = false - ) - ) - ) - - task.doNotTrackStateCompat("Tracked by external webpack tool") - - task.commonConfigure( - compilation = compilation, - dceTaskProvider = dceTaskProvider, - devDceTaskProvider = devDceTaskProvider, - mode = type, - configurationActions = runTaskConfigurations, - nodeJs = nodeJs, - defaultArchivesName = archivesName, - ) - } - - if (type == KotlinJsBinaryMode.DEVELOPMENT) { - target.runTask.dependsOn(runTask) - commonRunTask.configure { - it.dependsOn(runTask) - } - } - } - } - - private fun configureBuild( - compilation: KotlinJsCompilation, - dceTaskProvider: TaskProvider, - devDceTaskProvider: TaskProvider - ) { - val project = compilation.target.project - val nodeJs = project.rootProject.kotlinNodeJsExtension - - val processResourcesTask = target.project.tasks.named(compilation.processResourcesTaskName) - - val distributeResourcesTask = registerSubTargetTask( - disambiguateCamelCased( - DISTRIBUTE_RESOURCES_TASK_NAME - ) - ) { - it.from(processResourcesTask) - it.into(distribution.directory) - } - - val assembleTaskProvider = project.tasks.named(LifecycleBasePlugin.ASSEMBLE_TASK_NAME) - assembleTaskProvider.dependsOn(distributeResourcesTask) - - compilation.binaries - .all { binary -> - val type = binary.mode - val archivesName = project.archivesName - - val webpackTask = registerSubTargetTask( - disambiguateCamelCased( - binary.executeTaskBaseName, - WEBPACK_TASK_NAME - - ), - listOf(compilation) - ) { task -> - task.dependsOn( - distributeResourcesTask - ) - - task.description = "build webpack ${type.name.toLowerCaseAsciiOnly()} bundle" - task.outputDirectory.fileValue(distribution.directory).finalizeValueOnRead() - - BuildMetricsService.registerIfAbsent(project)?.let { - task.buildMetricsService.value(it) - } - - task.commonConfigure( - compilation = compilation, - dceTaskProvider = dceTaskProvider, - devDceTaskProvider = devDceTaskProvider, - mode = type, - configurationActions = webpackTaskConfigurations, - nodeJs = nodeJs, - defaultArchivesName = archivesName, - ) - } - - if (type == KotlinJsBinaryMode.PRODUCTION) { - assembleTaskProvider.dependsOn(webpackTask) - val webpackCommonTask = registerSubTargetTask( - disambiguateCamelCased(WEBPACK_TASK_NAME) - ) { - it.dependsOn(webpackTask) - } - registerSubTargetTask(disambiguateCamelCased(DISTRIBUTION_TASK_NAME)) { - it.dependsOn(webpackCommonTask) - it.dependsOn(distributeResourcesTask) - - it.outputs.dir(distribution.directory) - } - } - } - } - - private fun KotlinWebpack.commonConfigure( - compilation: KotlinJsCompilation, - dceTaskProvider: TaskProvider, - devDceTaskProvider: TaskProvider, - mode: KotlinJsBinaryMode, - configurationActions: List>, - nodeJs: NodeJsRootExtension, - defaultArchivesName: Property, - ) { - dependsOn( - nodeJs.npmInstallTaskProvider, - nodeJs.storeYarnLockTaskProvider, - target.project.tasks.named(compilation.processResourcesTaskName) - ) - - configureOptimization(mode) - - val actualDceTaskProvider = when (mode) { - KotlinJsBinaryMode.PRODUCTION -> dceTaskProvider - KotlinJsBinaryMode.DEVELOPMENT -> devDceTaskProvider - } - - dependsOn(actualDceTaskProvider) - - inputFilesDirectory.set( - actualDceTaskProvider.flatMap { dceTask -> - compilation.compileTaskProvider.flatMap { compileTask -> - dceTask.destinationDirectory - } - } - ) - - entryModuleName.set( - compilation.compileTaskProvider.flatMap { compileTask -> - compileTask.outputFileProperty.map { it.nameWithoutExtension } - } - ) - - this.esModules.convention(false).finalizeValueOnRead() - - resolveFromModulesFirst = true - - mainOutputFileName.convention(defaultArchivesName.orElse("main").map { "$it.js" }).finalizeValueOnRead() - - configurationActions.forEach { configure -> - configure.execute(this) - } - } - - private fun configureDce( - compilation: KotlinJsCompilation, - dev: Boolean - ): TaskProvider { - val project = compilation.target.project - - val dceTaskName = lowerCamelCaseName( - DCE_TASK_PREFIX, - if (dev) DCE_DEV_PART else null, - compilation.target.disambiguationClassifier, - compilation.name.takeIf { it != KotlinCompilation.MAIN_COMPILATION_NAME }, - DCE_TASK_SUFFIX - ) - - val kotlinTask = compilation.compileKotlinTaskProvider - - return project.registerTask(dceTaskName) { - if (dev) { - it.dceOptions.devMode = true - } else { - dceConfigurations.forEach { configure -> - configure.execute(it) - } - } - - it.kotlinFilesOnly = true - - it.libraries.from(project.configurations.getByName(compilation.runtimeDependencyConfigurationName)) - it.destinationDirectory.set( - it.dceOptions.outputDirectory?.let { File(it) } - ?: compilation.npmProject.dir.resolve(if (dev) DCE_DEV_DIR else DCE_DIR) - ) - it.defaultCompilerClasspath.setFrom(project.configurations.named(COMPILER_CLASSPATH_CONFIGURATION_NAME)) - it.runViaBuildToolsApi.value(false).disallowChanges() // The legacy backend task is not going to be supported - it.setSource(kotlinTask.map { it.outputFileProperty }) - } - } - - private fun KotlinWebpack.configureOptimization(kind: KotlinJsBinaryMode) { - mode = getByKind( - kind = kind, - releaseValue = Mode.PRODUCTION, - debugValue = Mode.DEVELOPMENT - ) - - devtool = getByKind( - kind = kind, - releaseValue = WebpackDevtool.SOURCE_MAP, - debugValue = WebpackDevtool.EVAL_SOURCE_MAP - ) - } - - private fun getByKind( - kind: KotlinJsBinaryMode, - releaseValue: T, - debugValue: T - ): T = when (kind) { - KotlinJsBinaryMode.PRODUCTION -> releaseValue - KotlinJsBinaryMode.DEVELOPMENT -> debugValue - } - - companion object { - const val DCE_TASK_PREFIX = "processDce" - private const val DCE_DEV_PART = "dev" - const val DCE_TASK_SUFFIX = "kotlinJs" - - const val DCE_DIR = "kotlin-dce" - const val DCE_DEV_DIR = "kotlin-dce-dev" - - const val PRODUCTION = "production" - const val DEVELOPMENT = "development" - - private const val WEBPACK_TASK_NAME = "webpack" - private const val DISTRIBUTE_RESOURCES_TASK_NAME = "distributeResources" - private const val DISTRIBUTION_TASK_NAME = "distribution" - } -} \ No newline at end of file +@Suppress("DEPRECATION") +@Deprecated("The Kotlin/JS legacy target is deprecated and its support completely discontinued", level = DeprecationLevel.HIDDEN) +abstract class KotlinBrowserJs : + KotlinJsSubTarget(), + KotlinJsBrowserDsl \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/subtargets/KotlinJsSubTarget.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/subtargets/KotlinJsSubTarget.kt index dd0e2441e4b..5caf1b372de 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/subtargets/KotlinJsSubTarget.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/subtargets/KotlinJsSubTarget.kt @@ -5,169 +5,7 @@ package org.jetbrains.kotlin.gradle.targets.js.subtargets -import org.gradle.api.Action -import org.gradle.api.NamedDomainObjectContainer -import org.gradle.api.Task -import org.gradle.api.plugins.ExtensionAware -import org.gradle.api.tasks.TaskProvider -import org.gradle.language.base.plugins.LifecycleBasePlugin -import org.jetbrains.kotlin.gradle.plugin.AbstractKotlinTargetConfigurator -import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation -import org.jetbrains.kotlin.gradle.plugin.KotlinTargetWithTests -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation -import org.jetbrains.kotlin.gradle.plugin.mpp.isMain -import org.jetbrains.kotlin.gradle.plugin.whenEvaluated -import org.jetbrains.kotlin.gradle.targets.js.KotlinJsPlatformTestRun -import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsSubTargetDsl -import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin.Companion.kotlinNodeJsExtension -import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject -import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest -import org.jetbrains.kotlin.gradle.tasks.registerTask -import org.jetbrains.kotlin.gradle.testing.internal.configureConventions -import org.jetbrains.kotlin.gradle.testing.internal.kotlinTestRegistry -import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName -abstract class KotlinJsSubTarget( - val target: KotlinJsTarget, - private val disambiguationClassifier: String -) : KotlinJsSubTargetDsl { - val project get() = target.project - - private val nodeJs = project.rootProject.kotlinNodeJsExtension - private val nodeJsTaskProviders = project.rootProject.kotlinNodeJsExtension - - abstract val testTaskDescription: String - - final override lateinit var testRuns: NamedDomainObjectContainer - private set - - protected val taskGroupName = "Kotlin $disambiguationClassifier" - - private val produceExecutable: Unit by lazy { - configureMain() - } - - internal fun produceExecutable() { - produceExecutable - } - - internal fun configure() { - configureTests() - - target.compilations.all { - val npmProject = it.npmProject - it.kotlinOptions { - outputFile = npmProject.dir.resolve(npmProject.main).canonicalPath - } - } - } - - override fun testTask(body: Action) { - testRuns.getByName(KotlinTargetWithTests.DEFAULT_TEST_RUN_NAME).executionTask.configure(body) - } - - protected fun disambiguateCamelCased(vararg names: String): String = - lowerCamelCaseName(target.disambiguationClassifier, disambiguationClassifier, *names) - - private fun configureTests() { - testRuns = project.container(KotlinJsPlatformTestRun::class.java) { name -> KotlinJsPlatformTestRun(name, target) }.also { - (this as ExtensionAware).extensions.add(this::testRuns.name, it) - } - - testRuns.all { configureTestRunDefaults(it) } - testRuns.create(KotlinTargetWithTests.DEFAULT_TEST_RUN_NAME) - } - - protected open fun configureTestRunDefaults(testRun: KotlinJsPlatformTestRun) { - target.compilations.matching { it.name == KotlinCompilation.TEST_COMPILATION_NAME }.all { compilation -> - configureTestsRun(testRun, compilation) - } - } - - private fun configureTestsRun(testRun: KotlinJsPlatformTestRun, compilation: KotlinJsCompilation) { - fun KotlinJsPlatformTestRun.subtargetTestTaskName(): String = disambiguateCamelCased( - lowerCamelCaseName( - name.takeIf { it != KotlinTargetWithTests.DEFAULT_TEST_RUN_NAME }, - AbstractKotlinTargetConfigurator.testTaskNameSuffix - ) - ) - - val testJs = project.registerTask( - testRun.subtargetTestTaskName(), - listOf(compilation) - ) { testJs -> - val compileTask = compilation.compileTaskProvider - - testJs.group = LifecycleBasePlugin.VERIFICATION_GROUP - testJs.description = testTaskDescription - - val compileOutputFile = compileTask.flatMap { it.outputFileProperty } - testJs.inputFileProperty.fileProvider(compileOutputFile) - - testJs.dependsOn( - nodeJsTaskProviders.npmInstallTaskProvider, - nodeJsTaskProviders.storeYarnLockTaskProvider, - compileTask, - nodeJsTaskProviders.nodeJsSetupTaskProvider - ) - - testJs.onlyIf { - compileOutputFile.get().exists() - } - - testJs.targetName = listOfNotNull(target.disambiguationClassifier, disambiguationClassifier) - .takeIf { it.isNotEmpty() } - ?.joinToString() - - testJs.configureConventions() - } - - testRun.executionTask = testJs - - target.testRuns.matching { it.name == testRun.name }.all { parentTestRun -> - target.project.kotlinTestRegistry.registerTestTask( - testJs, - parentTestRun.executionTask - ) - } - - project.whenEvaluated { - testJs.configure { - if (it.testFramework == null) { - configureDefaultTestFramework(it) - } - - if (it.enabled) { - nodeJs.taskRequirements.addTaskRequirements(it) - } - } - } - } - - protected abstract fun configureDefaultTestFramework(testTask: KotlinJsTest) - - private fun configureMain() { - target.compilations.all { compilation -> - if (compilation.isMain()) { - configureMain(compilation) - } - } - } - - protected abstract fun configureMain(compilation: KotlinJsCompilation) - - internal inline fun registerSubTargetTask( - name: String, - args: List = emptyList(), - noinline body: (T) -> (Unit) - ): TaskProvider = - project.registerTask(name, args) { - it.group = taskGroupName - body(it) - } - - companion object { - const val RUN_TASK_NAME = "run" - } -} +@Deprecated("The Kotlin/JS legacy target is deprecated and its support completely discontinued", level = DeprecationLevel.WARNING) +abstract class KotlinJsSubTarget : KotlinJsSubTargetDsl \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/subtargets/KotlinNodeJs.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/subtargets/KotlinNodeJs.kt index b59d8621d2a..983209a3e49 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/subtargets/KotlinNodeJs.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/subtargets/KotlinNodeJs.kt @@ -5,54 +5,10 @@ package org.jetbrains.kotlin.gradle.targets.js.subtargets -import org.gradle.api.Action -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation -import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget -import org.jetbrains.kotlin.gradle.targets.js.dsl.Distribution -import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalDistributionDsl import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsNodeDsl -import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec -import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest -import org.jetbrains.kotlin.gradle.tasks.dependsOn -import org.jetbrains.kotlin.gradle.tasks.withType -import javax.inject.Inject -abstract class KotlinNodeJs @Inject constructor(target: KotlinJsTarget) : - KotlinJsSubTarget(target, "node"), - KotlinJsNodeDsl { - override val testTaskDescription: String - get() = "Run all ${target.name} tests inside nodejs using the builtin test framework" - - private val runTaskName = disambiguateCamelCased("run") - - override fun runTask(body: Action) { - project.tasks.withType().named(runTaskName).configure(body) - } - - @ExperimentalDistributionDsl - override fun distribution(body: Action) { - TODO("Not yet implemented") - } - - override fun testTask(body: Action) { - super.testTask(body) - } - - override fun configureDefaultTestFramework(testTask: KotlinJsTest) { - testTask.useMocha { } - } - - override fun configureMain(compilation: KotlinJsCompilation) { - configureRun(compilation) - } - - private fun configureRun( - compilation: KotlinJsCompilation - ) { - val runTaskHolder = NodeJsExec.create(compilation, disambiguateCamelCased(RUN_TASK_NAME)) { - group = taskGroupName - inputFileProperty.fileProvider(compilation.compileKotlinTaskProvider.flatMap { it.outputFileProperty }) - } - target.runTask.dependsOn(runTaskHolder) - } -} \ No newline at end of file +@Suppress("DEPRECATION") +@Deprecated("The Kotlin/JS legacy target is deprecated and its support completely discontinued", level = DeprecationLevel.HIDDEN) +abstract class KotlinNodeJs : + KotlinJsSubTarget(), + KotlinJsNodeDsl \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/configuration/Kotlin2JsCompileConfig.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/configuration/Kotlin2JsCompileConfig.kt index 5056c0ca1c7..c1118afecb8 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/configuration/Kotlin2JsCompileConfig.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/configuration/Kotlin2JsCompileConfig.kt @@ -43,6 +43,7 @@ internal open class BaseKotlin2JsCompileConfig( } ) + @Suppress("DEPRECATION") task.destinationDirectory .convention( project.objects.directoryProperty().fileProvider( diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/regressionTests/ConfigurationsTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/regressionTests/ConfigurationsTest.kt index 5438a6b5f16..ecf22adcc4a 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/regressionTests/ConfigurationsTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/regressionTests/ConfigurationsTest.kt @@ -27,8 +27,8 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType 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.gradle.targets.js.ir.KotlinJsIrTarget import org.jetbrains.kotlin.gradle.util.* import org.jetbrains.kotlin.gradle.utils.toMap import java.util.* @@ -202,20 +202,6 @@ class ConfigurationsTest : MultiplatformExtensionTest() { "ImplementationDependenciesMetadata", ) - // allJs - val expectedAllJsConfigurations = commonSourceSetsConfigurationsToCheck - .map { project.configurations.getByName("allJs$it") } - - val actualAllJsConfigurations = expectedAllJsConfigurations - .filter { it.attributes.contains(KotlinJsCompilerAttribute.jsCompilerAttribute) } - - assertEquals( - expectedAllJsConfigurations, - actualAllJsConfigurations, - "JS-only configurations should contain KotlinJsCompilerAttribute" - ) - - // commonMain val actualCommonMainConfigurations = commonSourceSetsConfigurationsToCheck .map { project.configurations.getByName("commonMain$it") } @@ -233,10 +219,9 @@ class ConfigurationsTest : MultiplatformExtensionTest() { fun `test js IR compilation dependencies`() { val project = buildProjectWithMPP { kotlin { - @Suppress("DEPRECATION") - js(BOTH) - targets.withType { - irTarget!!.compilations.getByName("main").dependencies { + js() + targets.withType { + compilations.getByName("main").dependencies { api("test:compilation-dependency") } } @@ -267,8 +252,7 @@ class ConfigurationsTest : MultiplatformExtensionTest() { kotlin { jvm() - @Suppress("DEPRECATION") - js(BOTH) + js() linuxX64("linux") androidTarget() } @@ -307,8 +291,7 @@ class ConfigurationsTest : MultiplatformExtensionTest() { val project = buildProjectWithMPP { kotlin { jvm() - @Suppress("DEPRECATION") - js(BOTH) + js() linuxX64("linux") } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/KotlinHierarchyBuilderTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/KotlinHierarchyBuilderTest.kt index f4bb94340fe..e9e81a919c9 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/KotlinHierarchyBuilderTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/KotlinHierarchyBuilderTest.kt @@ -9,7 +9,6 @@ package org.jetbrains.kotlin.gradle.unitTests import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension import org.jetbrains.kotlin.gradle.plugin.KotlinHierarchyBuilder -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsTargetPreset import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmWithJavaTargetPreset import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTargetPreset import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinWasmTargetPreset @@ -27,7 +26,6 @@ class KotlinHierarchyBuilderTest { buildProjectWithMPP().multiplatformExtension.presets // JS targets are special and therefore are only handled manually using `withJs()` - .filter { it !is KotlinJsTargetPreset } .filter { it !is KotlinJsIrTargetPreset } .filter { it !is KotlinWasmTargetPreset } diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/compilerArgumetns/Kotlin2JsCompileArgumentsTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/compilerArgumetns/Kotlin2JsCompileArgumentsTest.kt index e998c24f541..756a64bfb0c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/compilerArgumetns/Kotlin2JsCompileArgumentsTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/compilerArgumetns/Kotlin2JsCompileArgumentsTest.kt @@ -10,12 +10,10 @@ package org.jetbrains.kotlin.gradle.unitTests.compilerArgumetns import org.jetbrains.kotlin.compilerRunner.ArgumentUtils import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension import org.jetbrains.kotlin.gradle.plugin.CreateCompilerArgumentsContext -import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.ArgumentType.PluginClasspath import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.ArgumentType.Primitive import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext.Companion.default import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext.Companion.lenient -import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.IR import org.jetbrains.kotlin.gradle.util.buildProjectWithMPP import org.jetbrains.kotlin.gradle.util.main