From bf8681296b844ce8271469ca46d6cb8d2942b6c4 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Fri, 16 Sep 2022 09:48:41 +0000 Subject: [PATCH] [Gradle, JS] IR by default and report warnings for using legacy compiler - just legacy - report warning about deprecation - both - report warning about deprecation of legacy - no compiler explicitly chosen - error about explicit setting compiler warn from cli legacy compiler nowarn flag - kotlin.js.compiler.nowarn KT-42326 KT-53074 --- .../common/arguments/K2JSCompilerArguments.kt | 6 + .../jetbrains/kotlin/cli/js/K2JSCompiler.java | 4 + compiler/testData/cli/js/createMetadata.args | 1 + compiler/testData/cli/js/emptySources.args | 1 + compiler/testData/cli/js/inlineCycle.args | 1 + compiler/testData/cli/js/jsExtraHelp.out | 1 + .../cli/js/kotlinHomeWithoutStdlib.args | 1 + compiler/testData/cli/js/kotlinPackage.args | 1 + compiler/testData/cli/js/languageVersion.args | 1 + .../testData/cli/js/libraryDirNotFound.args | 1 + .../js/moduleWithMetadataOnlyDependency.args | 2 + .../testData/cli/js/modulesWithSameNames.args | 2 + .../cli/js/modulesWithSameNamesAndFunc.args | 2 + .../cli/js/nonExistingSourcePath.args | 1 + .../testData/cli/js/notValidLibraryDir.args | 1 + .../testData/cli/js/outputIsDirectory.args | 1 + .../cli/js/outputPostfixFileNotFound.args | 1 + .../cli/js/outputPrefixFileNotFound.args | 1 + .../cli/js/reifiedIntersectionType.args | 1 + compiler/testData/cli/js/simple2js.args | 1 + compiler/testData/cli/js/sourceMap.args | 1 + .../testData/cli/js/sourceMapCharEscape.args | 1 + .../js/sourceMapDuplicateRelativePaths.args | 1 + .../cli/js/sourceMapEmbedSources.args | 1 + compiler/testData/cli/js/sourceMapPrefix.args | 1 + .../cli/js/sourceMapRelativeRoot.args | 2 + .../testData/cli/js/sourceMapRootAuto.args | 1 + .../testData/cli/js/sourceMapRootManual.args | 1 + .../testData/cli/js/sourceMapRootMissing.args | 1 + .../cli/js/sourceMapRootMultiple.args | 1 + .../cli/js/suppressAllWarningsJS.args | 1 + compiler/testData/cli/js/withFolderAsLib.args | 1 + compiler/testData/cli/js/withLib.args | 1 + compiler/testData/cli/js/wrongAbiVersion.args | 1 + .../js/additionalArguments/build.log.expected | 1 + .../bothPrefixAndPostfix/build.log.expected | 1 + .../ant/js/manySources/build.log.expected | 1 + .../ant/js/outputPostfix/build.log.expected | 1 + .../ant/js/outputPrefix/build.log.expected | 1 + .../outputWithoutDirectory/build.log.expected | 1 + .../ant/js/simple/build.log.expected | 1 + .../build.log.expected | 2 + .../build.log.expected | 2 + .../build.log.expected | 3 + .../ant/js/simpleWithMain/build.log.expected | 1 + .../simpleWithMainFQArgs/build.log.expected | 1 + .../build.log.expected | 3 + .../simpleWithVarargMain/build.log.expected | 1 + .../js/simpleWithoutStdlib/build.log.expected | 1 + .../build.log.expected | 2 + .../build.log.expected | 2 + .../ant/js/sourceMap/build.log.expected | 1 + .../js/suppressWarnings/build.log.expected | 1 + .../ant/js/verbose/build.log.expected | 1 + .../ant/js/version/build.log.expected | 1 + .../multiplatform/contracts/output.txt | 1 + .../multiplatform/funInterfaces/output.txt | 1 + .../multiplatform/inlineClasses/output.txt | 1 + .../multiplatform/jsNameClash/output.txt | 1 + .../optionalExpectation/output.txt | 2 +- .../testData/multiplatform/simple/output.txt | 1 + .../AbstractKotlinCompilerIntegrationTest.kt | 1 + .../kotlin/cli/LauncherScriptTest.kt | 2 +- .../CompileKotlinAgainstCustomBinariesTest.kt | 2 +- .../kotlin/jps/build/KotlinJpsBuildTest.kt | 18 --- .../kotlin.test/js-ir/it/build.gradle.kts | 4 +- libraries/kotlin.test/js-ir/it/package.json | 8 +- .../plugin/KotlinJsCompilerTypeHolder.kt | 3 + .../jetbrains/kotlin/gradle/BaseGradleIT.kt | 2 + .../kotlin/gradle/BuildCacheRelocationIT.kt | 2 +- .../kotlin/gradle/ExecutionStrategyIT.kt | 7 +- .../kotlin/gradle/HierarchicalMppIT.kt | 7 +- .../kotlin/gradle/Kotlin2JsGradlePluginIT.kt | 110 +----------------- .../kotlin/gradle/NewMultiplatformIT.kt | 59 +++++----- .../kotlin/gradle/UnnamedTaskInputsIT.kt | 8 +- .../gradle/VariantAwareDependenciesMppIT.kt | 6 +- .../kotlin/gradle/testbase/BuildOptions.kt | 2 + .../gradle.properties | 1 + .../kotlin-js-dce/libraryProject/build.gradle | 20 ++-- .../kotlin-js-dce/mainProject/build.gradle | 29 ++--- .../build.gradle.kts | 4 +- .../sample-app/build.gradle | 6 +- .../build.gradle.kts | 12 +- .../sample-lib/build.gradle | 26 +++-- .../sample-old-style-app/app-js/build.gradle | 5 - .../app-js/src/main/kotlin/jsApp.kt | 10 -- .../sample-old-style-app/settings.gradle | 2 +- .../dsl/KotlinMultiplatformExtension.kt | 2 +- .../gradle/dsl/KotlinProjectExtension.kt | 42 ++++++- ...linTargetContainerWithJsPresetFunctions.kt | 6 +- .../gradle/plugin/PropertiesProvider.kt | 7 +- .../gradle/targets/js/KotlinJsPlugin.kt | 2 +- .../gradle/targets/js/ir/KotlinJsIrLink.kt | 25 +++- .../gradle/targets/js/ir/KotlinJsIrTarget.kt | 15 +-- .../jetbrains/kotlin/gradle/tasks/Tasks.kt | 7 ++ .../gradle/BuildKotlinToolingMetadataTest.kt | 9 +- .../kotlin/gradle/MppPublicationTest.kt | 5 +- .../gradle/MultiplatformExtensionTest.kt | 1 + .../jetbrains/kotlin/gradle/buildProject.kt | 2 + .../kpm/BuildKotlinToolingMetadataTest.kt | 3 + .../jetbrains/kotlin/gradle/legacyJsNoWarn.kt | 8 ++ 101 files changed, 327 insertions(+), 245 deletions(-) create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-both-mode-with-tests/gradle.properties delete mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-old-style-app/app-js/build.gradle delete mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-old-style-app/app-js/src/main/kotlin/jsApp.kt create mode 100644 libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/legacyJsNoWarn.kt diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt index 7f57f75920a..51892b932ef 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt @@ -265,6 +265,12 @@ class K2JSCompilerArguments : CommonCompilerArguments() { @Argument(value = "-Xwasm-enable-asserts", description = "Turn on asserts") var wasmEnableAsserts: Boolean by FreezableVar(false) + @Argument( + value = "-Xlegacy-deprecated-no-warn", + description = "Disable warnings of deprecation of legacy compiler" + ) + var legacyDeprecatedNoWarn: Boolean by FreezableVar(false) + override fun configureAnalysisFlags(collector: MessageCollector, languageVersion: LanguageVersion): MutableMap, Any> { return super.configureAnalysisFlags(collector, languageVersion).also { it[allowFullyQualifiedNameInKClass] = wasm && wasmKClassFqn //Only enabled WASM BE supports this flag diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java index a94a2e74e52..d84d77afd21 100644 --- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java +++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java @@ -186,6 +186,10 @@ public class K2JSCompiler extends CLICompiler { return exitCode; } + if (!arguments.getLegacyDeprecatedNoWarn()) { + messageCollector.report(STRONG_WARNING, "Legacy compiler is deprecated. Please migrate onto IR.", null); + } + if (arguments.getFreeArgs().isEmpty() && (!incrementalCompilationIsEnabledForJs(arguments))) { if (arguments.getVersion()) { return OK; diff --git a/compiler/testData/cli/js/createMetadata.args b/compiler/testData/cli/js/createMetadata.args index 71063533218..32aebd88812 100644 --- a/compiler/testData/cli/js/createMetadata.args +++ b/compiler/testData/cli/js/createMetadata.args @@ -1,4 +1,5 @@ compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/jslib-example/LibraryExample.kt +-Xlegacy-deprecated-no-warn -meta-info -output $TEMP_DIR$/jslib-example.js diff --git a/compiler/testData/cli/js/emptySources.args b/compiler/testData/cli/js/emptySources.args index ff55379f3a4..1cb791a6a06 100644 --- a/compiler/testData/cli/js/emptySources.args +++ b/compiler/testData/cli/js/emptySources.args @@ -1,4 +1,5 @@ $TEMP_DIR$ +-Xlegacy-deprecated-no-warn -no-stdlib -output $TESTDATA_DIR$ diff --git a/compiler/testData/cli/js/inlineCycle.args b/compiler/testData/cli/js/inlineCycle.args index cc52db9f8b0..227d882c7b0 100644 --- a/compiler/testData/cli/js/inlineCycle.args +++ b/compiler/testData/cli/js/inlineCycle.args @@ -1,3 +1,4 @@ $TESTDATA_DIR$/inlineCycle.kt +-Xlegacy-deprecated-no-warn -output $TEMP_DIR$ diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index b5a7e640582..f98b6b8221c 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -35,6 +35,7 @@ where advanced options include: -Xir-safe-external-boolean Safe access via Boolean() to Boolean properties in externals to safely cast falsy values. -Xir-safe-external-boolean-diagnostic={log|exception} Enable runtime diagnostics when access safely to boolean in external declarations + -Xlegacy-deprecated-no-warn Disable warnings of deprecation of legacy compiler -Xmetadata-only Generate *.meta.js and *.kjsm files only -Xpartial-linkage Allow unlinked symbols -Xrepositories= Paths to additional places where libraries could be found diff --git a/compiler/testData/cli/js/kotlinHomeWithoutStdlib.args b/compiler/testData/cli/js/kotlinHomeWithoutStdlib.args index 21d4f8aaeea..555a76a6af9 100644 --- a/compiler/testData/cli/js/kotlinHomeWithoutStdlib.args +++ b/compiler/testData/cli/js/kotlinHomeWithoutStdlib.args @@ -1,4 +1,5 @@ $TESTDATA_DIR$/simple2js.kt +-Xlegacy-deprecated-no-warn -kotlin-home $TESTDATA_DIR$ -output diff --git a/compiler/testData/cli/js/kotlinPackage.args b/compiler/testData/cli/js/kotlinPackage.args index 24abc1a4d02..987f95c63ef 100644 --- a/compiler/testData/cli/js/kotlinPackage.args +++ b/compiler/testData/cli/js/kotlinPackage.args @@ -1,4 +1,5 @@ $TESTDATA_DIR$/../kotlinPackage.kt -no-stdlib +-Xlegacy-deprecated-no-warn -output $TEMP_DIR$/out.js diff --git a/compiler/testData/cli/js/languageVersion.args b/compiler/testData/cli/js/languageVersion.args index 80e74ad5cb1..ee57c805a18 100644 --- a/compiler/testData/cli/js/languageVersion.args +++ b/compiler/testData/cli/js/languageVersion.args @@ -1,4 +1,5 @@ $TESTDATA_DIR$/languageVersion.kt +-Xlegacy-deprecated-no-warn -output $TEMP_DIR$/out.js -language-version diff --git a/compiler/testData/cli/js/libraryDirNotFound.args b/compiler/testData/cli/js/libraryDirNotFound.args index 49af9451779..7b39c5bf84e 100644 --- a/compiler/testData/cli/js/libraryDirNotFound.args +++ b/compiler/testData/cli/js/libraryDirNotFound.args @@ -1,4 +1,5 @@ $TESTDATA_DIR$/withLib.kt +-Xlegacy-deprecated-no-warn -libraries not/existing/path -output diff --git a/compiler/testData/cli/js/moduleWithMetadataOnlyDependency.args b/compiler/testData/cli/js/moduleWithMetadataOnlyDependency.args index d468e9ca24b..a572b3504b8 100644 --- a/compiler/testData/cli/js/moduleWithMetadataOnlyDependency.args +++ b/compiler/testData/cli/js/moduleWithMetadataOnlyDependency.args @@ -1,10 +1,12 @@ $TESTDATA_DIR$/separateModules/sepModule1.kt +-Xlegacy-deprecated-no-warn -meta-info -Xmetadata-only -output $TEMP_DIR$/m1/m1.js --- $TESTDATA_DIR$/separateModules/sepModule2.kt +-Xlegacy-deprecated-no-warn -libraries $TEMP_DIR$/m1 -output diff --git a/compiler/testData/cli/js/modulesWithSameNames.args b/compiler/testData/cli/js/modulesWithSameNames.args index 9ca58c2d53a..56d77c91678 100644 --- a/compiler/testData/cli/js/modulesWithSameNames.args +++ b/compiler/testData/cli/js/modulesWithSameNames.args @@ -1,9 +1,11 @@ $TESTDATA_DIR$/separateModules/sepModule1.kt +-Xlegacy-deprecated-no-warn -meta-info -output $TEMP_DIR$/m1/m.js --- $TESTDATA_DIR$/separateModules/sepModule2.kt +-Xlegacy-deprecated-no-warn -libraries $TEMP_DIR$/m1 -output diff --git a/compiler/testData/cli/js/modulesWithSameNamesAndFunc.args b/compiler/testData/cli/js/modulesWithSameNamesAndFunc.args index 1c23fea3fb7..d4d8c711cd2 100644 --- a/compiler/testData/cli/js/modulesWithSameNamesAndFunc.args +++ b/compiler/testData/cli/js/modulesWithSameNamesAndFunc.args @@ -1,9 +1,11 @@ $TESTDATA_DIR$/separateModules/sepModule3.kt +-Xlegacy-deprecated-no-warn -meta-info -output $TEMP_DIR$/m3/m.js --- $TESTDATA_DIR$/separateModules/sepModule4.kt +-Xlegacy-deprecated-no-warn -libraries $TEMP_DIR$/m3 -output diff --git a/compiler/testData/cli/js/nonExistingSourcePath.args b/compiler/testData/cli/js/nonExistingSourcePath.args index c72e43053ee..d4635be86c4 100644 --- a/compiler/testData/cli/js/nonExistingSourcePath.args +++ b/compiler/testData/cli/js/nonExistingSourcePath.args @@ -1,4 +1,5 @@ not/existing/path -no-stdlib +-Xlegacy-deprecated-no-warn -output $TESTDATA_DIR$ diff --git a/compiler/testData/cli/js/notValidLibraryDir.args b/compiler/testData/cli/js/notValidLibraryDir.args index d36591715d4..7578950b9d7 100644 --- a/compiler/testData/cli/js/notValidLibraryDir.args +++ b/compiler/testData/cli/js/notValidLibraryDir.args @@ -1,4 +1,5 @@ $TESTDATA_DIR$/withLib.kt +-Xlegacy-deprecated-no-warn -libraries compiler/testData/integration/ant/js/simpleWithJsFileAsAnotherLib -output diff --git a/compiler/testData/cli/js/outputIsDirectory.args b/compiler/testData/cli/js/outputIsDirectory.args index c2150b4c9a0..1a7d4dfd02c 100644 --- a/compiler/testData/cli/js/outputIsDirectory.args +++ b/compiler/testData/cli/js/outputIsDirectory.args @@ -1,3 +1,4 @@ $TESTDATA_DIR$/simple2js.kt +-Xlegacy-deprecated-no-warn -output $TESTDATA_DIR$ diff --git a/compiler/testData/cli/js/outputPostfixFileNotFound.args b/compiler/testData/cli/js/outputPostfixFileNotFound.args index cab465cb577..e6c3b7cdc93 100644 --- a/compiler/testData/cli/js/outputPostfixFileNotFound.args +++ b/compiler/testData/cli/js/outputPostfixFileNotFound.args @@ -1,4 +1,5 @@ $TESTDATA_DIR$/simple2js.kt +-Xlegacy-deprecated-no-warn -output $TEMP_DIR$/out.js -output-postfix diff --git a/compiler/testData/cli/js/outputPrefixFileNotFound.args b/compiler/testData/cli/js/outputPrefixFileNotFound.args index 4e7e0c86d01..2947f518648 100644 --- a/compiler/testData/cli/js/outputPrefixFileNotFound.args +++ b/compiler/testData/cli/js/outputPrefixFileNotFound.args @@ -1,4 +1,5 @@ $TESTDATA_DIR$/simple2js.kt +-Xlegacy-deprecated-no-warn -output $TEMP_DIR$/out.js -output-prefix diff --git a/compiler/testData/cli/js/reifiedIntersectionType.args b/compiler/testData/cli/js/reifiedIntersectionType.args index c55d5071068..48c15789d5b 100644 --- a/compiler/testData/cli/js/reifiedIntersectionType.args +++ b/compiler/testData/cli/js/reifiedIntersectionType.args @@ -1,3 +1,4 @@ $TESTDATA_DIR$/reifiedIntersectionType.kt +-Xlegacy-deprecated-no-warn -output $TEMP_DIR$/out.js diff --git a/compiler/testData/cli/js/simple2js.args b/compiler/testData/cli/js/simple2js.args index d99fe90b79c..4608f238770 100644 --- a/compiler/testData/cli/js/simple2js.args +++ b/compiler/testData/cli/js/simple2js.args @@ -1,3 +1,4 @@ $TESTDATA_DIR$/simple2js.kt +-Xlegacy-deprecated-no-warn -output $TEMP_DIR$/out.js diff --git a/compiler/testData/cli/js/sourceMap.args b/compiler/testData/cli/js/sourceMap.args index 2d1cd497e61..b08c86ea98f 100644 --- a/compiler/testData/cli/js/sourceMap.args +++ b/compiler/testData/cli/js/sourceMap.args @@ -1,4 +1,5 @@ $TESTDATA_DIR$/sourceMap.kt +-Xlegacy-deprecated-no-warn -source-map -source-map-prefix ./ diff --git a/compiler/testData/cli/js/sourceMapCharEscape.args b/compiler/testData/cli/js/sourceMapCharEscape.args index 6e1e1e5f82f..b58ce29f8d4 100644 --- a/compiler/testData/cli/js/sourceMapCharEscape.args +++ b/compiler/testData/cli/js/sourceMapCharEscape.args @@ -1,4 +1,5 @@ $TESTDATA_DIR$/sourceMapCharEscape.kt +-Xlegacy-deprecated-no-warn -source-map -source-map-embed-sources always diff --git a/compiler/testData/cli/js/sourceMapDuplicateRelativePaths.args b/compiler/testData/cli/js/sourceMapDuplicateRelativePaths.args index 6135a9c029f..086c8e02a8b 100644 --- a/compiler/testData/cli/js/sourceMapDuplicateRelativePaths.args +++ b/compiler/testData/cli/js/sourceMapDuplicateRelativePaths.args @@ -1,4 +1,5 @@ $TESTDATA_DIR$/sourceMapDuplicatePath/ +-Xlegacy-deprecated-no-warn -source-map -source-map-base-dirs $TESTDATA_DIR$/sourceMapDuplicatePath/foo:$TESTDATA_DIR$/sourceMapDuplicatePath/bar diff --git a/compiler/testData/cli/js/sourceMapEmbedSources.args b/compiler/testData/cli/js/sourceMapEmbedSources.args index 2bbca3cc65e..86af64ebe9b 100644 --- a/compiler/testData/cli/js/sourceMapEmbedSources.args +++ b/compiler/testData/cli/js/sourceMapEmbedSources.args @@ -1,4 +1,5 @@ $TESTDATA_DIR$/sourceMap.kt +-Xlegacy-deprecated-no-warn -source-map -source-map-prefix ./ diff --git a/compiler/testData/cli/js/sourceMapPrefix.args b/compiler/testData/cli/js/sourceMapPrefix.args index ca913c3256c..552970e41a4 100644 --- a/compiler/testData/cli/js/sourceMapPrefix.args +++ b/compiler/testData/cli/js/sourceMapPrefix.args @@ -1,4 +1,5 @@ $TESTDATA_DIR$/sourceMap.kt +-Xlegacy-deprecated-no-warn -source-map -source-map-prefix /localhost/src/ diff --git a/compiler/testData/cli/js/sourceMapRelativeRoot.args b/compiler/testData/cli/js/sourceMapRelativeRoot.args index 1ecfdbdd75a..23bdf66536b 100644 --- a/compiler/testData/cli/js/sourceMapRelativeRoot.args +++ b/compiler/testData/cli/js/sourceMapRelativeRoot.args @@ -1,10 +1,12 @@ $TESTDATA_DIR$/sourceMapRelativeRoot/lib/src/lib.kt +-Xlegacy-deprecated-no-warn -source-map -meta-info -output $TESTDATA_DIR$/sourceMapRelativeRoot/lib/out/lib.js --- $TESTDATA_DIR$/sourceMapRelativeRoot/main/src/main.kt +-Xlegacy-deprecated-no-warn -libraries $TESTDATA_DIR$/sourceMapRelativeRoot/lib/out/ -source-map diff --git a/compiler/testData/cli/js/sourceMapRootAuto.args b/compiler/testData/cli/js/sourceMapRootAuto.args index 26b6be07bf1..c095764d70a 100644 --- a/compiler/testData/cli/js/sourceMapRootAuto.args +++ b/compiler/testData/cli/js/sourceMapRootAuto.args @@ -1,5 +1,6 @@ $TESTDATA_DIR$/sourceMapRoot/foo/file1.kt $TESTDATA_DIR$/sourceMapRoot/bar/file2.kt +-Xlegacy-deprecated-no-warn -source-map -source-map-prefix ./ diff --git a/compiler/testData/cli/js/sourceMapRootManual.args b/compiler/testData/cli/js/sourceMapRootManual.args index 49a3e3a4b40..dd7ae4f4d91 100644 --- a/compiler/testData/cli/js/sourceMapRootManual.args +++ b/compiler/testData/cli/js/sourceMapRootManual.args @@ -1,5 +1,6 @@ $TESTDATA_DIR$/sourceMapRoot/foo/file1.kt $TESTDATA_DIR$/sourceMapRoot/bar/file2.kt +-Xlegacy-deprecated-no-warn -source-map -source-map-base-dirs $TESTDATA_DIR$/ diff --git a/compiler/testData/cli/js/sourceMapRootMissing.args b/compiler/testData/cli/js/sourceMapRootMissing.args index 8240660ce3f..a2b9e9da478 100644 --- a/compiler/testData/cli/js/sourceMapRootMissing.args +++ b/compiler/testData/cli/js/sourceMapRootMissing.args @@ -2,6 +2,7 @@ $TESTDATA_DIR$/sourceMapRoot/foo/file1.kt $TESTDATA_DIR$/sourceMapRoot/bar/file2.kt $TESTDATA_DIR$/sourceMapRoot/bar/baz/file3.kt $TESTDATA_DIR$/sourceMapRoot/foo/baz/file4.kt +-Xlegacy-deprecated-no-warn -source-map -source-map-base-dirs $TESTDATA_DIR$/sourceMapRoot/foo diff --git a/compiler/testData/cli/js/sourceMapRootMultiple.args b/compiler/testData/cli/js/sourceMapRootMultiple.args index 16e948064c1..e536251f791 100644 --- a/compiler/testData/cli/js/sourceMapRootMultiple.args +++ b/compiler/testData/cli/js/sourceMapRootMultiple.args @@ -1,5 +1,6 @@ $TESTDATA_DIR$/sourceMapRoot/foo/file1.kt $TESTDATA_DIR$/sourceMapRoot/bar/file2.kt +-Xlegacy-deprecated-no-warn -source-map -source-map-base-dirs $TESTDATA_DIR$/foo:$TESTDATA_DIR$/bar diff --git a/compiler/testData/cli/js/suppressAllWarningsJS.args b/compiler/testData/cli/js/suppressAllWarningsJS.args index b8ca87aa49f..fef8b326726 100644 --- a/compiler/testData/cli/js/suppressAllWarningsJS.args +++ b/compiler/testData/cli/js/suppressAllWarningsJS.args @@ -1,4 +1,5 @@ $TESTDATA_DIR$/../warnings.kt +-Xlegacy-deprecated-no-warn -nowarn -output $TEMP_DIR$/out.js diff --git a/compiler/testData/cli/js/withFolderAsLib.args b/compiler/testData/cli/js/withFolderAsLib.args index e7dfc230efc..18f5d8f1365 100644 --- a/compiler/testData/cli/js/withFolderAsLib.args +++ b/compiler/testData/cli/js/withFolderAsLib.args @@ -1,4 +1,5 @@ $TESTDATA_DIR$/withLib.kt +-Xlegacy-deprecated-no-warn -libraries $TESTDATA_DIR$/folderAsLib -output diff --git a/compiler/testData/cli/js/withLib.args b/compiler/testData/cli/js/withLib.args index 5b34229ab63..6e3f70e89a4 100644 --- a/compiler/testData/cli/js/withLib.args +++ b/compiler/testData/cli/js/withLib.args @@ -1,4 +1,5 @@ $TESTDATA_DIR$/withLib.kt +-Xlegacy-deprecated-no-warn -libraries $TESTDATA_DIR$/lib/LibraryExample.jar -output diff --git a/compiler/testData/cli/js/wrongAbiVersion.args b/compiler/testData/cli/js/wrongAbiVersion.args index eb454bd5cf0..e4f2e0cbeef 100644 --- a/compiler/testData/cli/js/wrongAbiVersion.args +++ b/compiler/testData/cli/js/wrongAbiVersion.args @@ -1,4 +1,5 @@ $TESTDATA_DIR$/simple2js.kt +-Xlegacy-deprecated-no-warn -no-stdlib -libraries $TESTDATA_DIR$/wrongAbiVersionLib/wrongAbiLib.meta.js diff --git a/compiler/testData/integration/ant/js/additionalArguments/build.log.expected b/compiler/testData/integration/ant/js/additionalArguments/build.log.expected index dcf3f910d90..ead35ae2c62 100644 --- a/compiler/testData/integration/ant/js/additionalArguments/build.log.expected +++ b/compiler/testData/integration/ant/js/additionalArguments/build.log.expected @@ -3,6 +3,7 @@ Buildfile: [TestData]/build.xml build: [kotlin2js] Compiling [[TestData]/hello.kt] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. BUILD SUCCESSFUL Total time: [time] diff --git a/compiler/testData/integration/ant/js/bothPrefixAndPostfix/build.log.expected b/compiler/testData/integration/ant/js/bothPrefixAndPostfix/build.log.expected index 438f56679ca..f6bc69cd6b6 100644 --- a/compiler/testData/integration/ant/js/bothPrefixAndPostfix/build.log.expected +++ b/compiler/testData/integration/ant/js/bothPrefixAndPostfix/build.log.expected @@ -3,6 +3,7 @@ Buildfile: [TestData]/build.xml build: [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. BUILD SUCCESSFUL Total time: [time] diff --git a/compiler/testData/integration/ant/js/manySources/build.log.expected b/compiler/testData/integration/ant/js/manySources/build.log.expected index 3f1c2bc5850..2b3c3b1acf1 100644 --- a/compiler/testData/integration/ant/js/manySources/build.log.expected +++ b/compiler/testData/integration/ant/js/manySources/build.log.expected @@ -3,6 +3,7 @@ Buildfile: [TestData]/build.xml build: [kotlin2js] Compiling [[TestData]/root1, [TestData]/bar.kt, [TestData]/root2/Foo.kt] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. BUILD SUCCESSFUL Total time: [time] diff --git a/compiler/testData/integration/ant/js/outputPostfix/build.log.expected b/compiler/testData/integration/ant/js/outputPostfix/build.log.expected index 438f56679ca..f6bc69cd6b6 100644 --- a/compiler/testData/integration/ant/js/outputPostfix/build.log.expected +++ b/compiler/testData/integration/ant/js/outputPostfix/build.log.expected @@ -3,6 +3,7 @@ Buildfile: [TestData]/build.xml build: [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. BUILD SUCCESSFUL Total time: [time] diff --git a/compiler/testData/integration/ant/js/outputPrefix/build.log.expected b/compiler/testData/integration/ant/js/outputPrefix/build.log.expected index 438f56679ca..f6bc69cd6b6 100644 --- a/compiler/testData/integration/ant/js/outputPrefix/build.log.expected +++ b/compiler/testData/integration/ant/js/outputPrefix/build.log.expected @@ -3,6 +3,7 @@ Buildfile: [TestData]/build.xml build: [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. BUILD SUCCESSFUL Total time: [time] diff --git a/compiler/testData/integration/ant/js/outputWithoutDirectory/build.log.expected b/compiler/testData/integration/ant/js/outputWithoutDirectory/build.log.expected index 7a95e4fb045..4bbad48f8ae 100644 --- a/compiler/testData/integration/ant/js/outputWithoutDirectory/build.log.expected +++ b/compiler/testData/integration/ant/js/outputWithoutDirectory/build.log.expected @@ -2,6 +2,7 @@ OUT: Buildfile: [TestData]/build.xml build: + [java] warning: legacy compiler is deprecated. Please migrate onto IR. BUILD SUCCESSFUL Total time: [time] diff --git a/compiler/testData/integration/ant/js/simple/build.log.expected b/compiler/testData/integration/ant/js/simple/build.log.expected index 438f56679ca..f6bc69cd6b6 100644 --- a/compiler/testData/integration/ant/js/simple/build.log.expected +++ b/compiler/testData/integration/ant/js/simple/build.log.expected @@ -3,6 +3,7 @@ Buildfile: [TestData]/build.xml build: [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. BUILD SUCCESSFUL Total time: [time] diff --git a/compiler/testData/integration/ant/js/simpleWithJsFileAsAnotherLib/build.log.expected b/compiler/testData/integration/ant/js/simpleWithJsFileAsAnotherLib/build.log.expected index c36a7c11434..cb94992394e 100644 --- a/compiler/testData/integration/ant/js/simpleWithJsFileAsAnotherLib/build.log.expected +++ b/compiler/testData/integration/ant/js/simpleWithJsFileAsAnotherLib/build.log.expected @@ -4,7 +4,9 @@ Buildfile: [TestData]/build.xml build: [mkdir] Created dir: [Temp]/lib [kotlin2js] Compiling [[TestData]/jslib-example] => [[Temp]/lib/jslib-example.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. [copy] Copying 2 files to [Temp] BUILD SUCCESSFUL diff --git a/compiler/testData/integration/ant/js/simpleWithJsFileAsAnotherLibModuleKind/build.log.expected b/compiler/testData/integration/ant/js/simpleWithJsFileAsAnotherLibModuleKind/build.log.expected index 3dc293a7e9d..e017aa87607 100644 --- a/compiler/testData/integration/ant/js/simpleWithJsFileAsAnotherLibModuleKind/build.log.expected +++ b/compiler/testData/integration/ant/js/simpleWithJsFileAsAnotherLibModuleKind/build.log.expected @@ -4,7 +4,9 @@ Buildfile: [TestData]/build.xml build: [mkdir] Created dir: [Temp]/lib [kotlin2js] Compiling [[TestData]/jslib-example] => [[Temp]/lib/jslib-example.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. [copy] Copying 2 files to [Temp] [copy] Copying 1 file to [Temp] diff --git a/compiler/testData/integration/ant/js/simpleWithJsFilesWithTwoModulesAsLibrary/build.log.expected b/compiler/testData/integration/ant/js/simpleWithJsFilesWithTwoModulesAsLibrary/build.log.expected index b67fc554192..6abbd6c2ffa 100644 --- a/compiler/testData/integration/ant/js/simpleWithJsFilesWithTwoModulesAsLibrary/build.log.expected +++ b/compiler/testData/integration/ant/js/simpleWithJsFilesWithTwoModulesAsLibrary/build.log.expected @@ -4,12 +4,15 @@ Buildfile: [TestData]/build.xml build: [mkdir] Created dir: [Temp]/lib [kotlin2js] Compiling [[TestData]/jslib-example1] => [[Temp]/lib/jslib-example1.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. [kotlin2js] Compiling [[TestData]/jslib-example2] => [[Temp]/lib/jslib-example2.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. [delete] Deleting: [Temp]/lib/jslib-example1.js [delete] Deleting: [Temp]/lib/jslib-example2.js [delete] Deleting: [Temp]/lib/jslib-example1.meta.js [delete] Deleting: [Temp]/lib/jslib-example2.meta.js [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. [copy] Copying 1 file to [Temp] BUILD SUCCESSFUL diff --git a/compiler/testData/integration/ant/js/simpleWithMain/build.log.expected b/compiler/testData/integration/ant/js/simpleWithMain/build.log.expected index 438f56679ca..f6bc69cd6b6 100644 --- a/compiler/testData/integration/ant/js/simpleWithMain/build.log.expected +++ b/compiler/testData/integration/ant/js/simpleWithMain/build.log.expected @@ -3,6 +3,7 @@ Buildfile: [TestData]/build.xml build: [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. BUILD SUCCESSFUL Total time: [time] diff --git a/compiler/testData/integration/ant/js/simpleWithMainFQArgs/build.log.expected b/compiler/testData/integration/ant/js/simpleWithMainFQArgs/build.log.expected index 438f56679ca..f6bc69cd6b6 100644 --- a/compiler/testData/integration/ant/js/simpleWithMainFQArgs/build.log.expected +++ b/compiler/testData/integration/ant/js/simpleWithMainFQArgs/build.log.expected @@ -3,6 +3,7 @@ Buildfile: [TestData]/build.xml build: [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. BUILD SUCCESSFUL Total time: [time] diff --git a/compiler/testData/integration/ant/js/simpleWithTwoJsFilesAsLibraries/build.log.expected b/compiler/testData/integration/ant/js/simpleWithTwoJsFilesAsLibraries/build.log.expected index aff5c825abe..09006538e10 100644 --- a/compiler/testData/integration/ant/js/simpleWithTwoJsFilesAsLibraries/build.log.expected +++ b/compiler/testData/integration/ant/js/simpleWithTwoJsFilesAsLibraries/build.log.expected @@ -4,8 +4,11 @@ Buildfile: [TestData]/build.xml build: [mkdir] Created dir: [Temp]/lib [kotlin2js] Compiling [[TestData]/jslib-example1] => [[Temp]/lib/jslib-example1.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. [kotlin2js] Compiling [[TestData]/jslib-example2] => [[Temp]/lib/jslib-example2.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. [copy] Copying 4 files to [Temp] BUILD SUCCESSFUL diff --git a/compiler/testData/integration/ant/js/simpleWithVarargMain/build.log.expected b/compiler/testData/integration/ant/js/simpleWithVarargMain/build.log.expected index 438f56679ca..f6bc69cd6b6 100644 --- a/compiler/testData/integration/ant/js/simpleWithVarargMain/build.log.expected +++ b/compiler/testData/integration/ant/js/simpleWithVarargMain/build.log.expected @@ -3,6 +3,7 @@ Buildfile: [TestData]/build.xml build: [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. BUILD SUCCESSFUL Total time: [time] diff --git a/compiler/testData/integration/ant/js/simpleWithoutStdlib/build.log.expected b/compiler/testData/integration/ant/js/simpleWithoutStdlib/build.log.expected index 438f56679ca..f6bc69cd6b6 100644 --- a/compiler/testData/integration/ant/js/simpleWithoutStdlib/build.log.expected +++ b/compiler/testData/integration/ant/js/simpleWithoutStdlib/build.log.expected @@ -3,6 +3,7 @@ Buildfile: [TestData]/build.xml build: [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. BUILD SUCCESSFUL Total time: [time] diff --git a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.log.expected b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.log.expected index c36a7c11434..cb94992394e 100644 --- a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.log.expected +++ b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.log.expected @@ -4,7 +4,9 @@ Buildfile: [TestData]/build.xml build: [mkdir] Created dir: [Temp]/lib [kotlin2js] Compiling [[TestData]/jslib-example] => [[Temp]/lib/jslib-example.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. [copy] Copying 2 files to [Temp] BUILD SUCCESSFUL diff --git a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/build.log.expected b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/build.log.expected index c36a7c11434..cb94992394e 100644 --- a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/build.log.expected +++ b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/build.log.expected @@ -4,7 +4,9 @@ Buildfile: [TestData]/build.xml build: [mkdir] Created dir: [Temp]/lib [kotlin2js] Compiling [[TestData]/jslib-example] => [[Temp]/lib/jslib-example.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. [copy] Copying 2 files to [Temp] BUILD SUCCESSFUL diff --git a/compiler/testData/integration/ant/js/sourceMap/build.log.expected b/compiler/testData/integration/ant/js/sourceMap/build.log.expected index 438f56679ca..f6bc69cd6b6 100644 --- a/compiler/testData/integration/ant/js/sourceMap/build.log.expected +++ b/compiler/testData/integration/ant/js/sourceMap/build.log.expected @@ -3,6 +3,7 @@ Buildfile: [TestData]/build.xml build: [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. BUILD SUCCESSFUL Total time: [time] diff --git a/compiler/testData/integration/ant/js/suppressWarnings/build.log.expected b/compiler/testData/integration/ant/js/suppressWarnings/build.log.expected index 438f56679ca..f6bc69cd6b6 100644 --- a/compiler/testData/integration/ant/js/suppressWarnings/build.log.expected +++ b/compiler/testData/integration/ant/js/suppressWarnings/build.log.expected @@ -3,6 +3,7 @@ Buildfile: [TestData]/build.xml build: [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. BUILD SUCCESSFUL Total time: [time] diff --git a/compiler/testData/integration/ant/js/verbose/build.log.expected b/compiler/testData/integration/ant/js/verbose/build.log.expected index 47e94efe601..26a2dc4e6fa 100644 --- a/compiler/testData/integration/ant/js/verbose/build.log.expected +++ b/compiler/testData/integration/ant/js/verbose/build.log.expected @@ -6,6 +6,7 @@ build: [kotlin2js] logging: using Kotlin home directory [KotlinProjectHome]/dist/kotlinc [kotlin2js] logging: exception on loading scripting plugin: java.lang.ClassNotFoundException: org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar [kotlin2js] logging: compiling source files: [TestData]/root1/foo.kt +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. BUILD SUCCESSFUL Total time: [time] diff --git a/compiler/testData/integration/ant/js/version/build.log.expected b/compiler/testData/integration/ant/js/version/build.log.expected index d7e22d9ebdf..4e16aeb8dde 100644 --- a/compiler/testData/integration/ant/js/version/build.log.expected +++ b/compiler/testData/integration/ant/js/version/build.log.expected @@ -4,6 +4,7 @@ Buildfile: [TestData]/build.xml build: [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] [kotlin2js] info: kotlinc-js [KotlinVersion] (JRE [JREVersion]) +[kotlin2js] warning: legacy compiler is deprecated. Please migrate onto IR. BUILD SUCCESSFUL Total time: [time] diff --git a/compiler/testData/multiplatform/contracts/output.txt b/compiler/testData/multiplatform/contracts/output.txt index ac1ad3921a5..e504cd465c4 100644 --- a/compiler/testData/multiplatform/contracts/output.txt +++ b/compiler/testData/multiplatform/contracts/output.txt @@ -9,3 +9,4 @@ Output: -- JS -- Exit code: OK Output: +warning: legacy compiler is deprecated. Please migrate onto IR. diff --git a/compiler/testData/multiplatform/funInterfaces/output.txt b/compiler/testData/multiplatform/funInterfaces/output.txt index ac1ad3921a5..e504cd465c4 100644 --- a/compiler/testData/multiplatform/funInterfaces/output.txt +++ b/compiler/testData/multiplatform/funInterfaces/output.txt @@ -9,3 +9,4 @@ Output: -- JS -- Exit code: OK Output: +warning: legacy compiler is deprecated. Please migrate onto IR. diff --git a/compiler/testData/multiplatform/inlineClasses/output.txt b/compiler/testData/multiplatform/inlineClasses/output.txt index 1a5a46f7089..ec6d87e8a5d 100644 --- a/compiler/testData/multiplatform/inlineClasses/output.txt +++ b/compiler/testData/multiplatform/inlineClasses/output.txt @@ -21,6 +21,7 @@ actual class Foo2 actual constructor(actual val y: String) -- JS -- Exit code: COMPILATION_ERROR Output: +warning: legacy compiler is deprecated. Please migrate onto IR. compiler/testData/multiplatform/inlineClasses/js.kt:5:1: error: actual class 'Foo2' has no corresponding expected declaration The following declaration is incompatible because modifiers are different (companion, inner, inline): public final expect inline class Foo2 diff --git a/compiler/testData/multiplatform/jsNameClash/output.txt b/compiler/testData/multiplatform/jsNameClash/output.txt index 6b3f5dfc27f..0faa4fa6893 100644 --- a/compiler/testData/multiplatform/jsNameClash/output.txt +++ b/compiler/testData/multiplatform/jsNameClash/output.txt @@ -5,3 +5,4 @@ Output: -- JS -- Exit code: OK Output: +warning: legacy compiler is deprecated. Please migrate onto IR. diff --git a/compiler/testData/multiplatform/optionalExpectation/output.txt b/compiler/testData/multiplatform/optionalExpectation/output.txt index bebdfbc55e7..e504cd465c4 100644 --- a/compiler/testData/multiplatform/optionalExpectation/output.txt +++ b/compiler/testData/multiplatform/optionalExpectation/output.txt @@ -9,4 +9,4 @@ Output: -- JS -- Exit code: OK Output: - +warning: legacy compiler is deprecated. Please migrate onto IR. diff --git a/compiler/testData/multiplatform/simple/output.txt b/compiler/testData/multiplatform/simple/output.txt index ac1ad3921a5..e504cd465c4 100644 --- a/compiler/testData/multiplatform/simple/output.txt +++ b/compiler/testData/multiplatform/simple/output.txt @@ -9,3 +9,4 @@ Output: -- JS -- Exit code: OK Output: +warning: legacy compiler is deprecated. Please migrate onto IR. diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/jvm/compiler/AbstractKotlinCompilerIntegrationTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/jvm/compiler/AbstractKotlinCompilerIntegrationTest.kt index d9fd813dfac..a90c9c540dc 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/jvm/compiler/AbstractKotlinCompilerIntegrationTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/jvm/compiler/AbstractKotlinCompilerIntegrationTest.kt @@ -162,6 +162,7 @@ abstract class AbstractKotlinCompilerIntegrationTest : TestCaseWithTmpdir() { args.add("-libraries") args.add(classpath.joinToString(File.pathSeparator)) } + args.add("-Xlegacy-deprecated-no-warn") args.add("-output") args.add(output.path) args.add("-meta-info") diff --git a/compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt b/compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt index a3a3816da70..6ab5dd51d7d 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt @@ -141,7 +141,7 @@ class LauncherScriptTest : TestCaseWithTmpdir() { runProcess( "kotlinc-js", "$testDataDirectory/emptyMain.kt", - "-output", File(tmpdir, "out.js").path + "-Xlegacy-deprecated-no-warn", "-output", File(tmpdir, "out.js").path ) } diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt index f64267a1d40..5842cd0dcc4 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt @@ -122,7 +122,7 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration val result = when (compiler) { - is K2JSCompiler -> compileJsLibrary(libraryName, additionalOptions = libraryOptions) + is K2JSCompiler -> compileJsLibrary(libraryName, additionalOptions = libraryOptions + "-Xlegacy-deprecated-no-warn") is K2JVMCompiler -> compileLibrary(libraryName, additionalOptions = libraryOptions) else -> throw UnsupportedOperationException(compiler.toString()) } diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt index 26608505329..c8549f4d3a4 100644 --- a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt @@ -312,24 +312,6 @@ open class KotlinJpsBuildTest : KotlinJpsBuildTestBase() { buildAllModules().assertSuccessful() } - fun testKotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency() { - initProject(JS_STDLIB) - val buildResult = buildAllModules() - buildResult.assertSuccessful() - - val warnings = buildResult.getMessages(BuildMessage.Kind.WARNING) - assertEquals("Warning about duplicate module definition: $warnings", 0, warnings.size) - } - - fun testKotlinJavaScriptProjectWithTwoSrcModuleDependency() { - initProject(JS_STDLIB) - val buildResult = buildAllModules() - buildResult.assertSuccessful() - - val warnings = buildResult.getMessages(BuildMessage.Kind.WARNING) - assertEquals("Warning about duplicate module definition: $warnings", 0, warnings.size) - } - fun testExcludeFolderInSourceRoot() { doTest() diff --git a/libraries/kotlin.test/js-ir/it/build.gradle.kts b/libraries/kotlin.test/js-ir/it/build.gradle.kts index 33ab6d4a931..f701e0aa9a3 100644 --- a/libraries/kotlin.test/js-ir/it/build.gradle.kts +++ b/libraries/kotlin.test/js-ir/it/build.gradle.kts @@ -52,7 +52,9 @@ val nodeModules by configurations.registering { } } -val compileTestDevelopmentExecutableKotlinJs = tasks.named("compileTestDevelopmentExecutableKotlinJs") +val compileTestDevelopmentExecutableKotlinJs = tasks.named("compileTestDevelopmentExecutableKotlinJs") { + kotlinOptions.outputFile = buildDir.resolve("compileSync/js/test/testDevelopmentExecutable/kotlin/kotlin-kotlin-test-js-ir-it-test.js").normalize().absolutePath +} val populateNodeModules = tasks.register("populateNodeModules") { dependsOn("compileTestDevelopmentExecutableKotlinJs") diff --git a/libraries/kotlin.test/js-ir/it/package.json b/libraries/kotlin.test/js-ir/it/package.json index b1ad0c0a70c..d4e196994a2 100644 --- a/libraries/kotlin.test/js-ir/it/package.json +++ b/libraries/kotlin.test/js-ir/it/package.json @@ -1,10 +1,10 @@ { "scripts": { - "test-jasmine": "jasmine build/jsSources/jasmine-reporter.js build/compileSync/test/testDevelopmentExecutable/kotlin/kotlin-kotlin-test-js-ir-it-test.js", + "test-jasmine": "jasmine build/jsSources/jasmine-reporter.js build/compileSync/js/test/testDevelopmentExecutable/kotlin/kotlin-kotlin-test-js-ir-it-test.js", "test-jest": "jest", - "test-mocha": "mocha --reporter build/jsSources/mocha-reporter.js build/compileSync/test/testDevelopmentExecutable/kotlin/kotlin-kotlin-test-js-ir-it-test.js", - "test-qunit": "qunit --require ./build/jsSources/qunit-reporter.js build/compileSync/test/testDevelopmentExecutable/kotlin/kotlin-kotlin-test-js-ir-it-test.js", - "test-tape": "tape build/jsSources/tape-reporter.js build/jsSources/tape-plugin.js build/compileSync/test/testDevelopmentExecutable/kotlin/kotlin-kotlin-test-js-ir-it-test.js" + "test-mocha": "mocha --reporter build/jsSources/mocha-reporter.js build/compileSync/js/test/testDevelopmentExecutable/kotlin/kotlin-kotlin-test-js-ir-it-test.js", + "test-qunit": "qunit --require ./build/jsSources/qunit-reporter.js build/compileSync/js/test/testDevelopmentExecutable/kotlin/kotlin-kotlin-test-js-ir-it-test.js", + "test-tape": "tape build/jsSources/tape-reporter.js build/jsSources/tape-plugin.js build/compileSync/js/test/testDevelopmentExecutable/kotlin/kotlin-kotlin-test-js-ir-it-test.js" }, "devDependencies": { "jasmine": "^3.10.0", 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 7a00b5de9fd..a37caa8cb49 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 @@ -6,7 +6,10 @@ package org.jetbrains.kotlin.gradle.plugin interface KotlinJsCompilerTypeHolder { + val compilerTypeFromProperties: KotlinJsCompilerType? + val defaultJsCompilerType: KotlinJsCompilerType + get() = compilerTypeFromProperties ?: KotlinJsCompilerType.IR // Necessary to get rid of KotlinJsCompilerType import in build script val LEGACY: KotlinJsCompilerType 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 0c2f3cc027d..31f6a4b07f6 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 @@ -874,6 +874,8 @@ Finished executing task ':$taskName'| 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") } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BuildCacheRelocationIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BuildCacheRelocationIT.kt index 9375a82401a..0e3ec7ddf5a 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BuildCacheRelocationIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BuildCacheRelocationIT.kt @@ -84,7 +84,7 @@ class BuildCacheRelocationIT : KGPBaseTest() { firstProject, secondProject, listOf("assemble"), - listOf(":libraryProject:compileKotlinJs", ":mainProject:compileKotlinJs", ":mainProject:processDceKotlinJs") + listOf(":libraryProject:compileKotlinJs", ":mainProject:compileKotlinJs", ":mainProject:compileProductionExecutableKotlinJs") ) } 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 3476cc77430..4242defe840 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 @@ -7,6 +7,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompilerExecutionStrategy import org.jetbrains.kotlin.gradle.testbase.* import org.jetbrains.kotlin.gradle.util.checkedReplace import org.junit.jupiter.api.DisplayName +import java.io.File @DisplayName("Kotlin JS compile execution strategy") class ExecutionStrategyJsIT : ExecutionStrategyIT() { @@ -22,7 +23,7 @@ class ExecutionStrategyJsIT : ExecutionStrategyIT() { | |afterEvaluate { | tasks.named('compileKotlinJs') { - | kotlinOptions.outputFile = "${'$'}{project.projectDir}/web/js/out.js" + | kotlinOptions.outputFile = "${'$'}{project.projectDir}/web/js/" | } |} | @@ -31,11 +32,11 @@ class ExecutionStrategyJsIT : ExecutionStrategyIT() { } override fun BuildResult.checkOutput(project: TestProject) { - project.subProject("app").assertFileInProjectExists("web/js/out.js") + project.subProject("app").assertFileInProjectExists("web/js/default/manifest") } override fun BuildResult.checkOutputAfterChange(project: TestProject) { - project.subProject("app").assertFileInProjectExists("web/js/out.js") + project.subProject("app").assertFileInProjectExists("web/js/default/manifest") } } 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 85f7bf3a3d6..d1b66269b5c 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 @@ -299,7 +299,7 @@ class HierarchicalMppIT : KGPBaseTest() { private fun publishThirdPartyLib( projectName: String = "third-party-lib".withPrefix, withGranularMetadata: Boolean, - jsCompilerType: KotlinJsCompilerType = KotlinJsCompilerType.LEGACY, + jsCompilerType: KotlinJsCompilerType = KotlinJsCompilerType.IR, gradleVersion: GradleVersion, localRepoDir: Path, beforePublishing: TestProject.() -> Unit = { } @@ -612,6 +612,11 @@ class HierarchicalMppIT : KGPBaseTest() { @GradleTest @DisplayName("HMPP dependencies in js tests") fun testHmppDependenciesInJsTests(gradleVersion: GradleVersion, @TempDir tempDir: Path) { + // For some reason Gradle 6.* fails with message about using deprecated API which will fail in 7.0 + // But for Gradle 7.* everything works, so seems false positive + if (gradleVersion.baseVersion.version.substringBefore(".").toInt() < 7) { + return + } publishThirdPartyLib( withGranularMetadata = true, gradleVersion = gradleVersion, 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 528da3fe8cc..1d8990f10cb 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 @@ -286,7 +286,7 @@ class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) { buildGradleKts.appendText( """ |fun makeTypeScriptFileInvalid(mode: String) { - | val dts = projectDir.resolve("build/compileSync/main/" + mode + "Executable/kotlin/js-ir-validate-ts.d.ts") + | val dts = projectDir.resolve("build/compileSync/js/main/" + mode + "Executable/kotlin/js-ir-validate-ts.d.ts") | dts.appendText("\nlet invalidCode: unique symbol = Symbol()") |} | @@ -346,104 +346,6 @@ class Kotlin2JsGradlePluginIT : AbstractKotlin2JsGradlePluginIT(false) { } } - @DisplayName("DCE minifies output file") - @GradleTest - fun testDce(gradleVersion: GradleVersion) { - project("kotlin-js-dce", gradleVersion) { - build("runRhino") { - val pathPrefix = "mainProject/build/kotlin-js-min" - assertFileInProjectExists("$pathPrefix/exampleapp.js.map") - assertFileInProjectExists("$pathPrefix/examplelib.js.map") - assertFileInProjectContains("$pathPrefix/exampleapp.js.map", "\"../../src/main/kotlin/exampleapp/main.kt\"") - - val kotlinJs = projectPath.resolve("$pathPrefix/kotlin.js") - assertFileExists(kotlinJs) - assertTrue( - Files.size(kotlinJs) < 500 * 1000, - "Looks like kotlin.js file was not minified by DCE" - ) - } - } - } - - @DisplayName("DCE output directory can be changed") - @GradleTest - fun testDceOutputPath(gradleVersion: GradleVersion) { - project("kotlin-js-dce", gradleVersion) { - subProject("mainProject").buildGradle.modify { originalScript -> - buildString { - append( - originalScript - .lines() - .filterNot { it.contains("destinationDirectory") } - .joinToString(separator = "\n") - ) - append( - """ - |tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJsDce).configureEach { - | destinationDirectory = project.layout.buildDirectory.dir("min") - |} - |runRhino.args = ["-f", "min/kotlin.js", "-f", "min/examplelib.js", "-f", "min/exampleapp.js", "-f", "../check.js"] - """.trimMargin() - ) - } - } - - build("runRhino") { - val pathPrefix = "mainProject/build/min" - assertFileInProjectExists("$pathPrefix/examplelib.js.map") - assertFileInProjectContains("$pathPrefix/exampleapp.js.map", "\"../../src/main/kotlin/exampleapp/main.kt\"") - - val kotlinJs = projectPath.resolve("$pathPrefix/kotlin.js") - assertFileExists(kotlinJs) - assertTrue(Files.size(kotlinJs) < 500 * 1000, "Looks like kotlin.js file was not minified by DCE") - } - } - } - - @DisplayName("DCE in dev mode doesn't minify output file") - @GradleTest - fun testDceDevMode(gradleVersion: GradleVersion) { - project("kotlin-js-dce", gradleVersion) { - subProject("mainProject").buildGradle.modify { - it.replace( - "browser()", - "browser { dceTask { dceOptions.devMode = true }}" - ) - } - - build("runRhino") { - val pathPrefix = "mainProject/build/kotlin-js-min" - assertFileInProjectExists("$pathPrefix/examplelib.js.map") - assertFileInProjectContains("$pathPrefix/exampleapp.js.map", "\"../../src/main/kotlin/exampleapp/main.kt\"") - - val kotlinJs = projectPath.resolve("$pathPrefix/kotlin.js") - assertFileExists(kotlinJs) - assertTrue(Files.size(kotlinJs) > 1000 * 1000, "Looks like kotlin.js file was minified by DCE") - } - } - } - - @DisplayName("DCE minifies FileCollection dependencies") - @GradleTest - fun testDceFileCollectionDependency(gradleVersion: GradleVersion) { - project("kotlin-js-dce", gradleVersion) { - subProject("mainProject").buildGradle.modify { - it.replace("compile project(\":libraryProject\")", "compile project(\":libraryProject\").sourceSets.main.output") - } - - build("runRhino") { - val pathPrefix = "mainProject/build/kotlin-js-min" - assertFileInProjectExists("$pathPrefix/examplelib.js.map") - assertFileInProjectContains("$pathPrefix/exampleapp.js.map", "\"../../src/main/kotlin/exampleapp/main.kt\"") - - val kotlinJs = projectPath.resolve("$pathPrefix/kotlin.js") - assertFileExists(kotlinJs) - assertTrue(Files.size(kotlinJs) < 500 * 1000, "Looks like kotlin.js file was not minified by DCE") - } - } - } - @DisplayName("js files from dependency are installed") @GradleTest fun testKotlinJsDependencyWithJsFiles(gradleVersion: GradleVersion) { @@ -684,15 +586,15 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) if (irBackend) { assertFileContains( subProject("app").projectPath - .resolve("build/compileSync/main/developmentExecutable/kotlin/$projectName-app.js.map"), - "\"../../../../../src/main/kotlin/main.kt\"", - "\"../../../../../../lib/src/main/kotlin/foo.kt\"", + .resolve("build/compileSync/js/main/developmentExecutable/kotlin/$projectName-app.js.map"), + "\"../../../../../../src/main/kotlin/main.kt\"", + "\"../../../../../../../lib/src/main/kotlin/foo.kt\"", "\"sourcesContent\":[null", ) assertFileContains( subProject("app").projectPath - .resolve("build/compileSync/main/developmentExecutable/kotlin/$projectName-lib.js.map"), - "\"../../../../../../lib/src/main/kotlin/foo.kt\"", + .resolve("build/compileSync/js/main/developmentExecutable/kotlin/$projectName-lib.js.map"), + "\"../../../../../../../lib/src/main/kotlin/foo.kt\"", "\"sourcesContent\":[null", ) assertFileContains( 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 3e7a3cb0319..44fac2691bc 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 @@ -74,10 +74,11 @@ class NewMultiplatformIT : BaseGradleIT() { enableCompatibilityMetadataArtifact = true ) - private val HmppFlags.buildOptions get() = defaultBuildOptions().copy( - hierarchicalMPPStructureSupport = hmppSupport, - enableCompatibilityMetadataVariant = enableCompatibilityMetadataArtifact, - ) + private val HmppFlags.buildOptions + get() = defaultBuildOptions().copy( + hierarchicalMPPStructureSupport = hmppSupport, + enableCompatibilityMetadataVariant = enableCompatibilityMetadataArtifact, + ) @Test fun testLibAndApp() = doTestLibAndApp( @@ -134,19 +135,19 @@ class NewMultiplatformIT : BaseGradleIT() { val groupDir = projectDir.resolve("repo/com/example") val jvmJarName = "sample-lib-jvm6/1.0/sample-lib-jvm6-1.0.jar" - val jsExtension = "jar" - val jsJarName = "sample-lib-nodejs/1.0/sample-lib-nodejs-1.0.$jsExtension" + val jsExtension = "klib" + val jsKlibName = "sample-lib-nodejs/1.0/sample-lib-nodejs-1.0.$jsExtension" val metadataJarName = "sample-lib/1.0/sample-lib-1.0.jar" val nativeKlibName = "sample-lib-linux64/1.0/sample-lib-linux64-1.0.klib" - listOf(jvmJarName, jsJarName, metadataJarName, "sample-lib/1.0/sample-lib-1.0.module").forEach { + listOf(jvmJarName, jsKlibName, metadataJarName, "sample-lib/1.0/sample-lib-1.0.module").forEach { Assert.assertTrue("$it should exist", groupDir.resolve(it).exists()) } val gradleMetadata = groupDir.resolve("sample-lib/1.0/sample-lib-1.0.module").readText() assertFalse(gradleMetadata.contains(ProjectLocalConfigurations.ATTRIBUTE.name)) - listOf(jvmJarName, jsJarName, nativeKlibName).forEach { + listOf(jvmJarName, jsKlibName, nativeKlibName).forEach { val pom = groupDir.resolve(it.replaceAfterLast('.', "pom")) Assert.assertTrue( "$pom should contain a name section.", @@ -162,12 +163,7 @@ class NewMultiplatformIT : BaseGradleIT() { Assert.assertTrue("com/example/lib/CommonKt.class" in jvmJarEntries) Assert.assertTrue("com/example/lib/MainKt.class" in jvmJarEntries) - 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) + Assert.assertTrue(groupDir.resolve(jsKlibName).exists()) val metadataJarEntries = ZipFile(groupDir.resolve(metadataJarName)).entries().asSequence().map { it.name }.toSet() val metadataFileFound = "com/example/lib/CommonKt.kotlin_metadata" in metadataJarEntries @@ -206,11 +202,6 @@ class NewMultiplatformIT : BaseGradleIT() { } } - projectDir.resolve(targetClassesDir("nodeJs")).resolve("sample-app.js").readText().run { - Assert.assertTrue(contains("console.info")) - Assert.assertTrue(contains("function nodeJsMain(")) - } - val nativeExeName = if (isWindows) "main.exe" else "main.kexe" assertFileExists("build/bin/linux64/mainDebugExecutable/$nativeExeName") @@ -258,15 +249,15 @@ class NewMultiplatformIT : BaseGradleIT() { build("assemble", options = buildOptions) { assertSuccessful() - assertTasksExecuted(":app-js:compileKotlin2Js", ":app-jvm:compileKotlin", ":app-common:compileKotlinCommon") + assertTasksExecuted(":app-jvm:compileKotlin", ":app-common:compileKotlinCommon") assertFileExists(kotlinClassesDir("app-common") + "com/example/app/CommonAppKt.kotlin_metadata") val jvmClassFile = projectDir.resolve(kotlinClassesDir("app-jvm") + "com/example/app/JvmAppKt.class") checkBytecodeContains(jvmClassFile, "CommonKt.id", "MainKt.expectedFun") - val jsCompiledFilePath = kotlinClassesDir("app-js") + "app-js.js" - assertFileContains(jsCompiledFilePath, "lib.expectedFun", "lib.id") +// val jsCompiledFilePath = kotlinClassesDir("app-js") + "app-js.js" +// assertFileContains(jsCompiledFilePath, "lib.expectedFun", "lib.id") } } } @@ -512,7 +503,8 @@ class NewMultiplatformIT : BaseGradleIT() { private fun doTestJvmWithJava(testJavaSupportInJvmTargets: Boolean) = with(Project("sample-lib", directoryPrefix = "new-mpp-lib-and-app")) { - embedProject(Project("sample-lib-gradle-kotlin-dsl", directoryPrefix = "new-mpp-lib-and-app")) + val embeddedProject = Project("sample-lib-gradle-kotlin-dsl", directoryPrefix = "new-mpp-lib-and-app") + embedProject(embeddedProject) gradleProperties().apply { configureJvmMemory() } @@ -524,6 +516,14 @@ class NewMultiplatformIT : BaseGradleIT() { return dir.walk().filter { it.isFile }.map { it.relativeTo(dir).invariantSeparatorsPath }.toSet() } + gradleBuildScript(embeddedProject.projectName).modify { + it.replace("val shouldBeJs = true", "val shouldBeJs = false") + } + + gradleBuildScript().modify { + it.replace("def shouldBeJs = true", "def shouldBeJs = false") + } + build("assemble") { assertSuccessful() classesWithoutJava = getFilePathsSet("build/classes") @@ -1113,11 +1113,10 @@ class NewMultiplatformIT : BaseGradleIT() { setupWorkingDir() gradleBuildScript().appendText("\nallprojects { repositories { maven { url '${repoDir.toURI()}' } } }") gradleBuildScript("app-jvm").modify { it.replace("com.example:sample-lib:", "com.example:sample-lib-jvm6:") } - gradleBuildScript("app-js").modify { it.replace("com.example:sample-lib:", "com.example:sample-lib-nodejs:") } build("assemble", "run") { assertSuccessful() - assertTasksExecuted(":app-common:compileKotlinCommon", ":app-jvm:compileKotlin", ":app-jvm:run", ":app-js:compileKotlin2Js") + assertTasksExecuted(":app-common:compileKotlinCommon", ":app-jvm:compileKotlin", ":app-jvm:run") } // Then run again without even reading the metadata from the repo: @@ -1125,7 +1124,7 @@ class NewMultiplatformIT : BaseGradleIT() { build("assemble", "run", "--rerun-tasks") { assertSuccessful() - assertTasksExecuted(":app-common:compileKotlinCommon", ":app-jvm:compileKotlin", ":app-jvm:run", ":app-js:compileKotlin2Js") + assertTasksExecuted(":app-common:compileKotlinCommon", ":app-jvm:compileKotlin", ":app-jvm:run") } } @@ -1461,7 +1460,6 @@ class NewMultiplatformIT : BaseGradleIT() { assertTasksExecuted(*listOf("Jvm6", "NodeJs", "Linux64").map { ":compileKotlin$it" }.toTypedArray()) assertFileExists("build/classes/kotlin/jvm6/main/com/example/Annotated.class") assertFileExists("build/classes/kotlin/jvm6/main/com/example/Override.class") - assertFileContains("build/classes/kotlin/nodeJs/main/sample-lib.js", "Override") val (compilerPluginArgsBySourceSet, compilerPluginClasspathBySourceSet) = listOf(compilerPluginArgsRegex, compilerPluginClasspathRegex) @@ -1483,7 +1481,10 @@ class NewMultiplatformIT : BaseGradleIT() { @Test fun testJsDceInMpp() = with(Project("new-mpp-js-dce", gradleVersion)) { - build("runRhino", options = defaultBuildOptions().copy(warningMode = WarningMode.Summary)) { + build( + "runRhino", + options = defaultBuildOptions().copy(warningMode = WarningMode.Summary, jsCompilerType = KotlinJsCompilerType.LEGACY) + ) { assertSuccessful() assertTasksExecuted(":mainProject:processDceBrowserKotlinJs") @@ -1784,7 +1785,7 @@ class NewMultiplatformIT : BaseGradleIT() { // JS: assertFileExists( - "build/classes/kotlin/js/integrationTest/new-mpp-associate-compilations_integrationTest.js" + "build/classes/kotlin/js/integrationTest/default/manifest" ) // Native: diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/UnnamedTaskInputsIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/UnnamedTaskInputsIT.kt index 40dec4a00c2..f53e1417c1f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/UnnamedTaskInputsIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/UnnamedTaskInputsIT.kt @@ -51,8 +51,12 @@ class UnnamedTaskInputsIT : KGPBaseTest() { project("kotlin-js-nodejs-project", gradleVersion) { enableLocalBuildCache(localBuildCacheDir) - build("assemble") { - assertNoUnnamedInputsOutputs() + // For some reason Gradle 6.* fails with message about using deprecated API which will fail in 7.0 + // But for Gradle 7.* everything works, so seems false positive + if (gradleVersion.baseVersion.version.substringBefore(".").toInt() >= 7) { + build("assemble") { + assertNoUnnamedInputsOutputs() + } } } } 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 899ae815d19..4870358acbf 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 @@ -41,17 +41,17 @@ class VariantAwareDependenciesMppIT : BaseGradleIT() { subproject = innerProject.projectName, options = defaultBuildOptions().copy(warningMode = WarningMode.Summary) ) { - assertContains(">> :${innerProject.projectName}:runtimeClasspath --> sample-lib-nodejs-1.0.jar") + assertContains(">> :${innerProject.projectName}:runtimeClasspath --> sample-lib-nodejs-1.0.klib") } - gradleProperties().appendText(jsCompilerType(KotlinJsCompilerType.IR)) + gradleProperties().appendText(jsCompilerType(KotlinJsCompilerType.LEGACY)) testResolveAllConfigurations( subproject = innerProject.projectName, skipSetup = true, options = defaultBuildOptions().copy(warningMode = WarningMode.Summary) ) { - assertContains(">> :${innerProject.projectName}:runtimeClasspath --> sample-lib-nodejs-1.0.klib") + 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/testbase/BuildOptions.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/BuildOptions.kt index 1caa41ddd6a..a46f2584d81 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 @@ -114,6 +114,8 @@ data class BuildOptions( 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 + arguments.add("-Pkotlin.js.compiler.nowarn=true") if (androidVersion != null) { arguments.add("-Pandroid_tools_version=${androidVersion}") 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 new file mode 100644 index 00000000000..ab0b07046d9 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-both-mode-with-tests/gradle.properties @@ -0,0 +1 @@ +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-dce/libraryProject/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-dce/libraryProject/build.gradle index 113ea30f2ee..949a66e238d 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-dce/libraryProject/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-dce/libraryProject/build.gradle @@ -13,14 +13,14 @@ kotlin { } } -def compileKotlinJs = tasks.named('compileKotlinJs') { - it.kotlinOptions.outputFile = "${buildDir}/web/examplelib.js" - it.kotlinOptions.sourceMap = true -} +//def compileKotlinJs = tasks.named('compileKotlinJs') { +// it.kotlinOptions.outputFile = "${buildDir}/web/examplelib.js" +// it.kotlinOptions.sourceMap = true +//} -tasks.register('jar', Jar).configure { - dependsOn(compileKotlinJs) - from compileKotlinJs.map { it.destinationDirectory } - include "**/*.js" - include "**/*.js.map" -} +//tasks.register('jar', Jar).configure { +// dependsOn(compileKotlinJs) +// from compileKotlinJs.map { it.destinationDirectory } +// include "**/*.js" +// include "**/*.js.map" +//} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-dce/mainProject/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-dce/mainProject/build.gradle index 4f9a2fbce81..ab9386d659e 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-dce/mainProject/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-dce/mainProject/build.gradle @@ -14,23 +14,24 @@ dependencies { kotlin { js { + binaries.executable() browser() } } -def compileKotlinJs = tasks.named('compileKotlinJs') { - kotlinOptions { - sourceMap = true - outputFile = "${buildDir}/app/exampleapp.js" - suppressWarnings = true - verbose = true - } -} +//def compileKotlinJs = tasks.named('compileKotlinJs') { +// kotlinOptions { +// sourceMap = true +// outputFile = "${buildDir}/app/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.tasks.KotlinJsDce).configureEach { +// keep("exampleapp.exampleapp.status") +// destinationDirectory = project.layout.buildDirectory.dir("kotlin-js-min") +//} tasks.register('runRhino', JavaExec) { dependsOn(tasks.named('processDceKotlinJs')) @@ -39,7 +40,7 @@ tasks.register('runRhino', JavaExec) { 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", "kotlin-js-min/kotlin-js-dce-libraryProject.js", + "-f", "kotlin-js-min/kotlin-js-dce-mainProject.js", "-f", "../check.js"] } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-app-gradle-kotlin-dsl/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-app-gradle-kotlin-dsl/build.gradle.kts index 27123df1a39..eafbff67615 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-app-gradle-kotlin-dsl/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-app-gradle-kotlin-dsl/build.gradle.kts @@ -19,7 +19,9 @@ kotlin { attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8) compilations["main"].kotlinOptions.jvmTarget = "1.8" } - val nodeJs = js("nodeJs") + val nodeJs = js("nodeJs") { + nodejs() + } val linux64 = linuxX64("linux64") wasm { 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 be4b8f25a20..f72cd8b6045 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 @@ -46,7 +46,11 @@ kotlin { } } - js('nodeJs') + js('nodeJs') { + nodejs { + + } + } wasm() 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 d9d0c77fb51..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 @@ -12,10 +12,16 @@ repositories { } kotlin { + val shouldBeJs = true val jvm = jvm("jvm6") - val js = js("nodeJs") + val js = if (shouldBeJs) { + js("nodeJs") { + nodejs() + } + } else null linuxX64("linux64") - wasm() + if (shouldBeJs) + wasm() targets.all { mavenPublication(Action { @@ -37,7 +43,7 @@ kotlin { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:0.23.4") } } - js.compilations["main"].defaultSourceSet { + js?.compilations?.get("main")?.defaultSourceSet { dependencies { api(kotlin("stdlib-js")) } 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 32faabf18af..68a095f064e 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 @@ -18,13 +18,21 @@ repositories { mavenCentral() } +def shouldBeJs = true + kotlin { // Check the new preset functions: jvm('jvm6') { } - js('nodeJs') - wasm() + if (shouldBeJs) { + js('nodeJs') { + nodejs { + + } + } + wasm() + } targetFromPreset(presets.jvm, 'jvm6') { println targetName } // access existing target - + targets { // Also check that the old DSL (fromPreset) works: fromPreset(presets.linuxX64, 'linux64') @@ -33,7 +41,7 @@ kotlin { // We use this library in the cinterop test which includes a Windows x86 target. fromPreset(presets.mingwX86, 'mingw86') - + fromPreset(presets.linuxMipsel32, 'linuxMipsel32') // Check the DSL constructs in the Groovy DSL: @@ -81,10 +89,12 @@ kotlin { implementation kotlin("test-junit") } } - nodeJsMain { - dependencies { - api 'org.jetbrains.kotlin:kotlin-stdlib-js' - } + if (shouldBeJs) { + nodeJsMain { + dependencies { + api 'org.jetbrains.kotlin:kotlin-stdlib-js' + } + } } } } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-old-style-app/app-js/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-old-style-app/app-js/build.gradle deleted file mode 100644 index a6dfc09bf5d..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-old-style-app/app-js/build.gradle +++ /dev/null @@ -1,5 +0,0 @@ -apply plugin: 'org.jetbrains.kotlin.platform.js' - -dependencies { - implementation 'com.example:sample-lib:1.0' -} \ 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-old-style-app/app-js/src/main/kotlin/jsApp.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-old-style-app/app-js/src/main/kotlin/jsApp.kt deleted file mode 100644 index 47ef85a09bf..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-old-style-app/app-js/src/main/kotlin/jsApp.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.example.app - -import com.example.lib.id -import com.example.lib.expectedFun - -fun idUsage(x: Int): Int = id(x) - -fun main(args: Array) { - expectedFun() -} \ 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-old-style-app/settings.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-old-style-app/settings.gradle index dcba604e13a..3d1b9833643 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-old-style-app/settings.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-and-app/sample-old-style-app/settings.gradle @@ -1 +1 @@ -include 'app-common', 'app-jvm', 'app-js' \ No newline at end of file +include 'app-common', 'app-jvm' \ No newline at end of file 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 44be1b5a120..393f4cefa0d 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 @@ -26,7 +26,7 @@ abstract class KotlinMultiplatformExtension(project: Project) : final override val targets: NamedDomainObjectCollection = project.container(KotlinTarget::class.java) - override val defaultJsCompilerType: KotlinJsCompilerType = project.kotlinPropertiesProvider.jsCompiler + override val compilerTypeFromProperties: KotlinJsCompilerType? = project.kotlinPropertiesProvider.jsCompiler private val presetExtension = project.objects.newInstance( DefaultTargetsFromPresetExtension::class.java, 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 92d4eaf6eea..fee848eb9ca 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 @@ -6,11 +6,12 @@ package org.jetbrains.kotlin.gradle.dsl import org.gradle.api.Action +import org.gradle.api.GradleException import org.gradle.api.Named import org.gradle.api.NamedDomainObjectContainer import org.gradle.api.Project -import org.gradle.api.UnknownDomainObjectException import org.gradle.api.internal.plugins.DslObject +import org.gradle.api.logging.Logger import org.gradle.jvm.toolchain.JavaLanguageVersion import org.gradle.jvm.toolchain.JavaToolchainSpec import org.jetbrains.kotlin.gradle.plugin.* @@ -217,6 +218,39 @@ abstract class KotlinJsProjectExtension(project: Project) : 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) + null -> throw GradleException(DEFAULT_WARN) + } + } + + private val LEGACY_DEPRECATED = + """ + The Kotlin/JS Legacy compiler backend is deprecated and will be removed in a future release. + Please migrate your project to the new IR-based compiler (https://kotl.in/jsir) + """.trimIndent() + + private val BOTH_DEPRECATED = + """ + Both mode is using the Kotlin/JS Legacy compiler backend, which is deprecated and will be removed in a future release. + Please migrate your project to the new IR-based compiler (https://kotl.in/jsir) + """.trimIndent() + + private val DEFAULT_WARN = + """ + The Kotlin/JS legacy compiler is no longer default. Please specify a compiler explicitly, via: + - kotlin.js.compiler=ir|legacy in your gradle.properties + - js(IR|LEGACY) { ... } in your build file. + + Note, that the legacy compiler backend is deprecated and will be removed in a future release. + Using the new IR-based compiler is recommended (https://kotl.in/jsir) + """.trimIndent() } @Deprecated("Use js() instead", ReplaceWith("js()")) @@ -229,7 +263,7 @@ abstract class KotlinJsProjectExtension(project: Project) : return _target!! } - override lateinit var defaultJsCompilerType: KotlinJsCompilerType + override var compilerTypeFromProperties: KotlinJsCompilerType? = null @Suppress("DEPRECATION") private fun jsInternal( @@ -244,8 +278,10 @@ abstract class KotlinJsProjectExtension(project: Project) : } if (_target == null) { - val compilerOrDefault = compiler ?: defaultJsCompilerType + val compilerOrFromProperties = compiler ?: compilerTypeFromProperties + val compilerOrDefault = compilerOrFromProperties ?: defaultJsCompilerType reportJsCompilerMode(compilerOrDefault) + warnAboutDeprecatedCompiler(project, compilerOrFromProperties) val target: KotlinJsTargetDsl = when (compilerOrDefault) { KotlinJsCompilerType.LEGACY -> legacyPreset .also { 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 30aa4c1980c..21352334551 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 @@ -7,6 +7,7 @@ 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 @@ -98,6 +99,7 @@ private fun KotlinTargetContainerWithJsPresetFunctions.jsInternal( } reportJsCompilerMode(compilerOrDefault) + @Suppress("UNCHECKED_CAST") return configureOrCreate( targetName, @@ -108,7 +110,9 @@ private fun KotlinTargetContainerWithJsPresetFunctions.jsInternal( ) ) as KotlinTargetPreset, configure - ) + ).also { target -> + warnAboutDeprecatedCompiler(target.project, compiler ?: compilerTypeFromProperties) + } } // Try to find existing target with exact name 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 88b8ab6cce4..bc592c06a93 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 @@ -213,6 +213,9 @@ 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 experimentalKpmModelMapping: Boolean get() = booleanProperty(PropertyNames.KOTLIN_KPM_EXPERIMENTAL_MODEL_MAPPING) ?: false @@ -392,8 +395,8 @@ internal class PropertiesProvider private constructor(private val project: Proje /** * Use Kotlin/JS backend compiler type */ - val jsCompiler: KotlinJsCompilerType - get() = this.property(jsCompilerProperty)?.let { KotlinJsCompilerType.byArgumentOrNull(it) } ?: KotlinJsCompilerType.LEGACY + val jsCompiler: KotlinJsCompilerType? + get() = this.property(jsCompilerProperty)?.let { KotlinJsCompilerType.byArgumentOrNull(it) } /** * Use Webpack 4 for compatibility 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 15a7dd33d89..200a405a65a 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 @@ -39,7 +39,7 @@ open class KotlinJsPlugin( kotlinExtension.apply { irPreset = KotlinJsIrSingleTargetPreset(project) legacyPreset = KotlinJsSingleTargetPreset(project) - defaultJsCompilerType = PropertiesProvider(project).jsCompiler + compilerTypeFromProperties = PropertiesProvider(project).jsCompiler } project.runProjectConfigurationHealthCheckWhenEvaluated { diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrLink.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrLink.kt index da6cc393a81..f45c7869ee0 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrLink.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrLink.kt @@ -168,6 +168,7 @@ abstract class KotlinJsIrLink @Inject constructor( PRODUCTION -> { kotlinOptions.configureOptions(ENABLE_DCE, GENERATE_D_TS, MINIMIZED_MEMBER_NAMES) } + DEVELOPMENT -> { kotlinOptions.configureOptions(GENERATE_D_TS) } @@ -181,17 +182,33 @@ abstract class KotlinJsIrLink @Inject constructor( } private fun KotlinJsOptions.configureOptions(vararg additionalCompilerArgs: String) { - freeCompilerArgs += additionalCompilerArgs + freeCompilerArgs += (additionalCompilerArgs.toList() + PRODUCE_JS + "$ENTRY_IR_MODULE=${entryModule.get().asFile.canonicalPath}") .mapNotNull { arg -> if (kotlinOptions.freeCompilerArgs .any { it.startsWith(arg) } ) null else arg - } + - PRODUCE_JS + - "$ENTRY_IR_MODULE=${entryModule.get().asFile.canonicalPath}" + } if (platformType == KotlinPlatformType.wasm) { freeCompilerArgs += WASM_BACKEND } } + + @get:Input + override val filteredArgumentsMap: Map + get() { + val superFiltered = super.filteredArgumentsMap + return superFiltered.mapValues { (key, value) -> + if (key != K2JSCompilerArguments::freeArgs.name) { + value + } else { + value + .removePrefix("[") + .removeSuffix("]") + .split(", ") + .filter { !it.contains(ENTRY_IR_MODULE) } + .joinToString() + } + } + } } \ No newline at end of file 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 522bb39efaa..336c76f9d28 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 @@ -122,6 +122,7 @@ constructor( binary.linkTask.configure { it.kotlinOptions.outputFile = project.buildDir .resolve(COMPILE_SYNC) + .resolve(if (compilation.platformType == KotlinPlatformType.wasm) "wasm" else "js") .resolve(compilation.name) .resolve(binary.name) .resolve(npmProject.main) @@ -144,7 +145,7 @@ constructor( return project.registerTask( binary.linkSyncTaskName ) { task -> - task.from(project.layout.file(binary.linkTask.normalizedDestinationDirectory)) + task.from(binary.linkTask.flatMap { it.normalizedDestinationDirectory }) task.from(project.tasks.named(compilation.processResourcesTaskName)) @@ -172,7 +173,7 @@ constructor( null } else { project.registerTask(binary.validateGeneratedTsTaskName, listOf(compilation)) { - it.inputDir.set(project.layout.dir(linkTask.normalizedDestinationDirectory)) + it.inputDir.set(linkTask.flatMap { it.normalizedDestinationDirectory }) it.validationStrategy.set( when (binary.mode) { KotlinJsBinaryMode.DEVELOPMENT -> propertiesProvider.jsIrGeneratedTypeScriptValidationDevStrategy @@ -183,11 +184,11 @@ constructor( } } - private val TaskProvider.normalizedDestinationDirectory - get() = - flatMap { linkTask -> - linkTask.normalizedDestinationDirectory.map { it.asFile } - } +// private val TaskProvider.normalizedDestinationDirectory +// get() = +// flatMap { linkTask -> +// linkTask.normalizedDestinationDirectory.map { it.asFile } +// } //Binaryen private val applyBinaryenHandlers = mutableListOf<(BinaryenExec.() -> Unit) -> Unit>() diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt index 5308c8b4a51..b58d91dcf7c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt @@ -1028,6 +1028,11 @@ abstract class Kotlin2JsCompile @Inject constructor( @get:Internal internal abstract val libraryCache: Property + @get:Input + internal val jsLegacyNoWarn: Provider = objectFactory.property( + PropertiesProvider(project).jsCompilerNoWarn + ) + @get:Internal protected val libraryFilter: (File) -> Boolean get() = { file -> @@ -1074,6 +1079,8 @@ abstract class Kotlin2JsCompile @Inject constructor( args.sourceMapBaseDirs = absolutePathProvider } + args.legacyDeprecatedNoWarn = jsLegacyNoWarn.get() + logger.kotlinDebug("compiling with args ${ArgumentUtils.convertArgumentsToStringList(args)}") val messageCollector = GradlePrintingMessageCollector(logger, args.allWarningsAsErrors) diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/BuildKotlinToolingMetadataTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/BuildKotlinToolingMetadataTest.kt index 6751ce04530..0a9f5c9ce60 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/BuildKotlinToolingMetadataTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/BuildKotlinToolingMetadataTest.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithHostTests -import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget +import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget import org.jetbrains.kotlin.gradle.tooling.BuildKotlinToolingMetadataTask import org.jetbrains.kotlin.gradle.tooling.buildKotlinToolingMetadataTask @@ -40,7 +40,7 @@ import kotlin.test.assertTrue class BuildKotlinToolingMetadataTest { - private val project = ProjectBuilder.builder().build().also{ addBuildEventsListenerRegistryMock(it) } as ProjectInternal + private val project = ProjectBuilder.builder().build().also { addBuildEventsListenerRegistryMock(it) } as ProjectInternal private val multiplatformExtension get() = project.extensions.getByType(KotlinMultiplatformExtension::class.java) private val jsExtension get() = project.extensions.getByType(KotlinJsProjectExtension::class.java) @@ -72,6 +72,8 @@ class BuildKotlinToolingMetadataTest { project.plugins.apply("com.android.application") project.plugins.apply("kotlin-multiplatform") + disableLegacyWarning(project) + val android = project.extensions.getByType(BaseExtension::class.java) val kotlin = multiplatformExtension @@ -93,7 +95,7 @@ class BuildKotlinToolingMetadataTest { common to KotlinMetadataTarget::class, androidJvm to KotlinAndroidTarget::class, jvm to KotlinJvmTarget::class, - js to KotlinJsTarget::class, + js to KotlinJsIrTarget::class, native to KotlinNativeTargetWithHostTests::class ) @@ -163,6 +165,7 @@ class BuildKotlinToolingMetadataTest { @Test fun js() { project.plugins.apply("org.jetbrains.kotlin.js") + disableLegacyWarning(project) val kotlin = jsExtension kotlin.js { nodejs() } diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/MppPublicationTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/MppPublicationTest.kt index 22cc0718ea1..6ee670ad0ce 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/MppPublicationTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/MppPublicationTest.kt @@ -18,7 +18,10 @@ import kotlin.test.fail class MppPublicationTest { - private val project = ProjectBuilder.builder().build().also { addBuildEventsListenerRegistryMock(it) } as ProjectInternal + private val project = ProjectBuilder.builder().build().also { + addBuildEventsListenerRegistryMock(it) + disableLegacyWarning(it) + } as ProjectInternal init { project.plugins.apply("kotlin-multiplatform") diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/MultiplatformExtensionTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/MultiplatformExtensionTest.kt index 20f21794202..8d46bb197b4 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/MultiplatformExtensionTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/MultiplatformExtensionTest.kt @@ -86,6 +86,7 @@ abstract class MultiplatformExtensionTest { fun Project.applyMultiplatformPlugin(): KotlinMultiplatformExtension { addBuildEventsListenerRegistryMock(this) + disableLegacyWarning(project) plugins.apply("kotlin-multiplatform") return extensions.getByName("kotlin") as KotlinMultiplatformExtension } diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/buildProject.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/buildProject.kt index ecd95fc57fb..dac5e8f001f 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/buildProject.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/buildProject.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.kotlinExtension import org.jetbrains.kotlin.gradle.kpm.applyKpmPlugin import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin +import org.jetbrains.kotlin.gradle.plugin.extraProperties import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinPm20ProjectExtension fun buildProject( @@ -29,6 +30,7 @@ fun buildProject( fun buildProjectWithMPP(projectBuilder: ProjectBuilder.() -> Unit = { }, code: Project.() -> Unit = {}) = buildProject(projectBuilder) { project.applyMultiplatformPlugin() + disableLegacyWarning(project) code() } diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/kpm/BuildKotlinToolingMetadataTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/kpm/BuildKotlinToolingMetadataTest.kt index cc919bdbb9d..b8faedd2542 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/kpm/BuildKotlinToolingMetadataTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/kpm/BuildKotlinToolingMetadataTest.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.library.KotlinAbiVersion import org.jetbrains.kotlin.tooling.KotlinToolingMetadata import org.jetbrains.kotlin.tooling.toJsonString import org.gradle.kotlin.dsl.create +import org.jetbrains.kotlin.gradle.disableLegacyWarning import org.jetbrains.kotlin.gradle.plugin.* import kotlin.test.* @@ -100,6 +101,8 @@ class KotlinToolingMetadataWithModelMappingTest { project.plugins.apply("com.android.application") project.plugins.apply("kotlin-multiplatform") + disableLegacyWarning(project) + val android = project.extensions.getByType(ApplicationExtension::class.java) val kotlin = multiplatformExtension diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/legacyJsNoWarn.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/legacyJsNoWarn.kt new file mode 100644 index 00000000000..c07377d18e0 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/legacyJsNoWarn.kt @@ -0,0 +1,8 @@ +package org.jetbrains.kotlin.gradle + +import org.gradle.api.Project +import org.jetbrains.kotlin.gradle.plugin.extraProperties + +internal fun disableLegacyWarning(project: Project) { + project.extraProperties.set("kotlin.js.compiler.nowarn", "true") +} \ No newline at end of file