diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/libraries/CompilerExecutor.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/libraries/CompilerExecutor.kt index 5cadeddd77c..0f9b252cf62 100644 --- a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/libraries/CompilerExecutor.kt +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/libraries/CompilerExecutor.kt @@ -73,7 +73,6 @@ internal object CompilerExecutor { } CompilerKind.JS -> { val commands = buildList { - add(K2JSCompilerArguments::metaInfo.cliArgument) add(K2JSCompilerArguments::moduleName.cliArgument); add(libraryName) add(K2JSCompilerArguments::outputDir.cliArgument); add(library.parent.absolutePathString()) add(K2JSCompilerArguments::irProduceKlibFile.cliArgument) diff --git a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArgumentsCopyGenerated.kt b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArgumentsCopyGenerated.kt index c2aee1ecf81..c257e4e39ec 100644 --- a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArgumentsCopyGenerated.kt +++ b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArgumentsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode") +@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt diff --git a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonToolArgumentsCopyGenerated.kt b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonToolArgumentsCopyGenerated.kt index 3e30c556b80..542f88ff512 100644 --- a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonToolArgumentsCopyGenerated.kt +++ b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonToolArgumentsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode") +@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt diff --git a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArgumentsCopyGenerated.kt b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArgumentsCopyGenerated.kt index fb839ca4f3a..163e89c80e8 100644 --- a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArgumentsCopyGenerated.kt +++ b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArgumentsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode") +@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt @@ -15,7 +15,6 @@ fun copyK2JSCompilerArguments(from: K2JSCompilerArguments, to: K2JSCompilerArgum to.errorTolerancePolicy = from.errorTolerancePolicy to.extensionFunctionsInExternals = from.extensionFunctionsInExternals to.fakeOverrideValidator = from.fakeOverrideValidator - to.forceDeprecatedLegacyCompilerUsage = from.forceDeprecatedLegacyCompilerUsage to.friendModules = from.friendModules to.friendModulesDisabled = from.friendModulesDisabled to.generateDts = from.generateDts @@ -46,15 +45,11 @@ fun copyK2JSCompilerArguments(from: K2JSCompilerArguments, to: K2JSCompilerArgum to.libraries = from.libraries to.main = from.main to.metaInfo = from.metaInfo - to.metadataOnly = from.metadataOnly to.moduleKind = from.moduleKind to.moduleName = from.moduleName - to.noStdlib = from.noStdlib to.optimizeGeneratedJs = from.optimizeGeneratedJs to.outputDir = from.outputDir to.outputFile = from.outputFile - to.outputPostfix = from.outputPostfix - to.outputPrefix = from.outputPrefix to.partialLinkageLogLevel = from.partialLinkageLogLevel to.partialLinkageMode = from.partialLinkageMode to.platformArgumentsProviderJsExpression = from.platformArgumentsProviderJsExpression diff --git a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSDceArgumentsCopyGenerated.kt b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSDceArgumentsCopyGenerated.kt index e5437efccb3..4ff37f6b725 100644 --- a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSDceArgumentsCopyGenerated.kt +++ b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSDceArgumentsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode") +@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt diff --git a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArgumentsCopyGenerated.kt b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArgumentsCopyGenerated.kt index b5f7336a682..1832e76f3d2 100644 --- a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArgumentsCopyGenerated.kt +++ b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArgumentsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode") +@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt diff --git a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2MetadataCompilerArgumentsCopyGenerated.kt b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2MetadataCompilerArgumentsCopyGenerated.kt index b9ac7f83a9d..7af3b36446d 100644 --- a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2MetadataCompilerArgumentsCopyGenerated.kt +++ b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2MetadataCompilerArgumentsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode") +@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt diff --git a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2NativeCompilerArgumentsCopyGenerated.kt b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2NativeCompilerArgumentsCopyGenerated.kt index 65ae92a369c..1bf0c9eec3a 100644 --- a/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2NativeCompilerArgumentsCopyGenerated.kt +++ b/compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2NativeCompilerArgumentsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode") +@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.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 9aa0704c348..9af4de0957c 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 @@ -16,16 +16,7 @@ class K2JSCompilerArguments : CommonCompilerArguments() { @JvmStatic private val serialVersionUID = 0L } - @GradleOption( - value = DefaultValue.STRING_NULL_DEFAULT, - gradleInputType = GradleInputTypes.INTERNAL, // handled by task 'outputFileProperty' - shouldGenerateDeprecatedKotlinOptions = true, - ) - @GradleDeprecatedOption( - message = "Only for legacy backend. For IR backend please use task.destinationDirectory and moduleName", - level = DeprecationLevel.WARNING, - removeAfter = "1.9.0" - ) + @Deprecated("It is senseless to use with IR compiler. Only for compatibility.") @Argument(value = "-output", valueDescription = "", description = "Destination *.js file for the compilation result.") var outputFile: String? = null set(value) { @@ -52,18 +43,6 @@ class K2JSCompilerArguments : CommonCompilerArguments() { field = if (value.isNullOrEmpty()) null else value } - @GradleOption( - value = DefaultValue.BOOLEAN_TRUE_DEFAULT, - gradleInputType = GradleInputTypes.INPUT, - shouldGenerateDeprecatedKotlinOptions = true, - ) - @Argument(value = "-no-stdlib", description = "Don't automatically include the default Kotlin/JS stdlib in compilation dependencies.") - var noStdlib = false - set(value) { - checkFrozen() - field = value - } - @Argument( value = "-libraries", valueDescription = "", @@ -147,11 +126,7 @@ class K2JSCompilerArguments : CommonCompilerArguments() { field = if (value.isNullOrEmpty()) null else value } - @GradleOption( - value = DefaultValue.BOOLEAN_TRUE_DEFAULT, - gradleInputType = GradleInputTypes.INPUT, - shouldGenerateDeprecatedKotlinOptions = true, - ) + @Deprecated("It is senseless to use with IR compiler. Only for compatibility.") @Argument(value = "-meta-info", description = "Generate .meta.js and .kjsm files with metadata. Use this to create a library.") var metaInfo = false set(value) { @@ -214,28 +189,6 @@ class K2JSCompilerArguments : CommonCompilerArguments() { field = if (value.isNullOrEmpty()) null else value } - @Argument( - value = "-output-prefix", - valueDescription = "", - description = "Add the content of the specified file to the beginning of the output file." - ) - var outputPrefix: String? = null - set(value) { - checkFrozen() - field = if (value.isNullOrEmpty()) null else value - } - - @Argument( - value = "-output-postfix", - valueDescription = "", - description = "Add the content of the specified file to the end of the output file." - ) - var outputPostfix: String? = null - set(value) { - checkFrozen() - field = if (value.isNullOrEmpty()) null else value - } - // Advanced options @Argument( @@ -559,13 +512,6 @@ In combination with '-meta-info', this generates both IR and pre-IR versions of field = value } - @Argument(value = "-Xmetadata-only", description = "Generate .meta.js and .kjsm files only.") - var metadataOnly = false - set(value) { - checkFrozen() - field = value - } - @Argument(value = "-Xenable-js-scripting", description = "Enable experimental support for .kts files using K/JS (with '-Xir' only).") var enableJsScripting = false set(value) { @@ -660,16 +606,6 @@ In combination with '-meta-info', this generates both IR and pre-IR versions of field = value } - @Argument( - value = "-Xforce-deprecated-legacy-compiler-usage", - description = "This flag is used only for our inner infrastructure. It will soon be removed, so it's no longer safe to use." - ) - var forceDeprecatedLegacyCompilerUsage = false - set(value) { - checkFrozen() - field = value - } - @Argument( value = "-Xoptimize-generated-js", description = "Perform additional optimizations on the generated JS code." @@ -739,8 +675,5 @@ In combination with '-meta-info', this generates both IR and pre-IR versions of override fun copyOf(): Freezable = copyK2JSCompilerArguments(this, K2JSCompilerArguments()) } -fun K2JSCompilerArguments.isPreIrBackendDisabled(): Boolean = - irOnly || irProduceJs || irProduceKlibFile || irBuildCache || useK2 - fun K2JSCompilerArguments.isIrBackendEnabled(): Boolean = irProduceKlibDir || irProduceJs || irProduceKlibFile || wasm || irBuildCache || useK2 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 45fea2fa278..c1d00e9a550 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 @@ -70,9 +70,6 @@ import static org.jetbrains.kotlin.cli.common.UtilsKt.incrementalCompilationIsEn import static org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*; public class K2JSCompiler extends CLICompiler { - private static final Map moduleKindMap = new HashMap<>(); - private static final Map sourceMapContentEmbeddingMap = new LinkedHashMap<>(); - private K2JsIrCompiler irCompiler = null; @NotNull @@ -85,18 +82,6 @@ public class K2JSCompiler extends CLICompiler { @Override protected void addPlatformOptions(@NotNull List $self, @NotNull K2JSCompilerArguments arguments) {} - static { - moduleKindMap.put(K2JsArgumentConstants.MODULE_PLAIN, ModuleKind.PLAIN); - moduleKindMap.put(K2JsArgumentConstants.MODULE_COMMONJS, ModuleKind.COMMON_JS); - moduleKindMap.put(K2JsArgumentConstants.MODULE_AMD, ModuleKind.AMD); - moduleKindMap.put(K2JsArgumentConstants.MODULE_UMD, ModuleKind.UMD); - moduleKindMap.put(K2JsArgumentConstants.MODULE_ES, ModuleKind.ES); - - sourceMapContentEmbeddingMap.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_ALWAYS, SourceMapSourceEmbedding.ALWAYS); - sourceMapContentEmbeddingMap.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_NEVER, SourceMapSourceEmbedding.NEVER); - sourceMapContentEmbeddingMap.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_INLINING, SourceMapSourceEmbedding.INLINING); - } - public static void main(String... args) { doMain(new K2JSCompiler(), args); } @@ -109,61 +94,6 @@ public class K2JSCompiler extends CLICompiler { return new K2JSCompilerArguments(); } - @NotNull - private static TranslationResult translate( - @NotNull JsConfig.Reporter reporter, - @NotNull List allKotlinFiles, - @NotNull JsAnalysisResult jsAnalysisResult, - @NotNull MainCallParameters mainCallParameters, - @NotNull JsConfig config - ) throws TranslationException { - K2JSTranslator translator = new K2JSTranslator(config); - IncrementalDataProvider incrementalDataProvider = config.getConfiguration().get(JSConfigurationKeys.INCREMENTAL_DATA_PROVIDER); - if (incrementalDataProvider != null) { - Map nonCompiledSources = new HashMap<>(allKotlinFiles.size()); - for (KtFile ktFile : allKotlinFiles) { - nonCompiledSources.put(VfsUtilCore.virtualToIoFile(ktFile.getVirtualFile()), ktFile); - } - - Map compiledParts = incrementalDataProvider.getCompiledPackageParts(); - - File[] allSources = new File[compiledParts.size() + allKotlinFiles.size()]; - int i = 0; - for (File file : compiledParts.keySet()) { - allSources[i++] = file; - } - for (File file : nonCompiledSources.keySet()) { - allSources[i++] = file; - } - Arrays.sort(allSources); - - Set dirtyPackages = nonCompiledSources.values().stream().map(KtFile::getPackageFqName).collect(Collectors.toSet()); - Map packageMetadata = new HashMap<>(); - for (Map.Entry e : incrementalDataProvider.getPackageMetadata().entrySet()) { - FqName name = new FqName(e.getKey()); - if (!dirtyPackages.contains(name)) { - packageMetadata.put(name, e.getValue()); - } - } - - List translationUnits = new ArrayList<>(); - for (i = 0; i < allSources.length; i++) { - KtFile nonCompiled = nonCompiledSources.get(allSources[i]); - if (nonCompiled != null) { - translationUnits.add(new TranslationUnit.SourceFile(nonCompiled)); - } - else { - TranslationResultValue translatedValue = compiledParts.get(allSources[i]); - translationUnits.add(new TranslationUnit.BinaryAst(translatedValue.getBinaryAst(), translatedValue.getInlineData())); - } - } - return translator.translateUnits(reporter, translationUnits, mainCallParameters, jsAnalysisResult, packageMetadata); - } - - CollectionsKt.sortBy(allKotlinFiles, ktFile -> VfsUtilCore.virtualToIoFile(ktFile.getVirtualFile())); - return translator.translate(reporter, allKotlinFiles, mainCallParameters, jsAnalysisResult); - } - @NotNull @Override protected ExitCode doExecute( @@ -174,228 +104,13 @@ public class K2JSCompiler extends CLICompiler { ) { MessageCollector messageCollector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY); - ExitCode exitCode = OK; - boolean useFir = Boolean.TRUE.equals(configuration.get(CommonConfigurationKeys.USE_FIR)); if (K2JSCompilerArgumentsKt.isIrBackendEnabled(arguments) || useFir) { - exitCode = getIrCompiler().doExecute(arguments, configuration.copy(), rootDisposable, paths); - } - if (K2JSCompilerArgumentsKt.isPreIrBackendDisabled(arguments) || useFir) { - return exitCode; + return getIrCompiler().doExecute(arguments, configuration.copy(), rootDisposable, paths); } - LanguageVersionSettings languageVersionSettings = CommonConfigurationKeysKt.getLanguageVersionSettings(configuration); - - if (!arguments.getForceDeprecatedLegacyCompilerUsage() && languageVersionSettings.getLanguageVersion().compareTo(LanguageVersion.KOTLIN_1_9) >= 0) { - messageCollector.report(ERROR, "Old Kotlin/JS compiler is no longer supported. Please migrate to the new JS IR backend", null); - return COMPILATION_ERROR; - } - - if (arguments.getFreeArgs().isEmpty() && (!incrementalCompilationIsEnabledForJs(arguments))) { - if (arguments.getVersion()) { - return OK; - } - messageCollector.report(ERROR, "Specify at least one source file or directory", null); - return COMPILATION_ERROR; - } - - ExitCode pluginLoadResult = loadPlugins(paths, arguments, configuration); - if (pluginLoadResult != ExitCode.OK) return pluginLoadResult; - - configuration.put(JSConfigurationKeys.LIBRARIES, configureLibraries(arguments, paths, messageCollector)); - - String[] commonSourcesArray = arguments.getCommonSources(); - Set commonSources = commonSourcesArray == null ? Collections.emptySet() : SetsKt.setOf(commonSourcesArray); - for (String arg : arguments.getFreeArgs()) { - ContentRootsKt.addKotlinSourceRoot(configuration, arg, commonSources.contains(arg)); - } - - KotlinCoreEnvironment environmentForJS = - KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.JS_CONFIG_FILES); - - Project project = environmentForJS.getProject(); - List sourcesFiles = environmentForJS.getSourceFiles(); - - environmentForJS.getConfiguration().put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.getAllowKotlinPackage()); - environmentForJS.getConfiguration().put(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME, arguments.getRenderInternalDiagnosticNames()); - - - if (!HelpersKt.checkKotlinPackageUsageForPsi(environmentForJS.getConfiguration(), sourcesFiles)) return ExitCode.COMPILATION_ERROR; - - if (arguments.getOutputFile() == null) { - messageCollector.report(ERROR, "Specify output file via -output", null); - return ExitCode.COMPILATION_ERROR; - } - - if (messageCollector.hasErrors()) { - return ExitCode.COMPILATION_ERROR; - } - - if (sourcesFiles.isEmpty() && !incrementalCompilationIsEnabledForJs(arguments)) { - messageCollector.report(ERROR, "No source files", null); - return COMPILATION_ERROR; - } - - if (arguments.getVerbose()) { - reportCompiledSourcesList(messageCollector, sourcesFiles); - } - - File outputFile = new File(arguments.getOutputFile()); - - configuration.put(CommonConfigurationKeys.MODULE_NAME, FileUtil.getNameWithoutExtension(outputFile)); - - JsConfig config = new JsConfig(project, configuration, CompilerEnvironment.INSTANCE); - JsConfig.Reporter reporter = new JsConfig.Reporter() { - @Override - public void error(@NotNull String message) { - messageCollector.report(ERROR, message, null); - } - - @Override - public void warning(@NotNull String message) { - messageCollector.report(STRONG_WARNING, message, null); - } - }; - if (config.checkLibFilesAndReportErrors(reporter)) { - return COMPILATION_ERROR; - } - - AnalysisResult analysisResult; - do { - AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport( - messageCollector, - CommonConfigurationKeysKt.getLanguageVersionSettings(configuration), - configuration.getBoolean(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME) - ); - List sources = environmentForJS.getSourceFiles(); - analyzerWithCompilerReport.analyzeAndReport(sourcesFiles, () -> TopDownAnalyzerFacadeForJS.analyzeFiles(sources, config)); - if (analyzerWithCompilerReport.hasErrors()) { - return COMPILATION_ERROR; - } - - ProgressIndicatorAndCompilationCanceledStatus.checkCanceled(); - analysisResult = analyzerWithCompilerReport.getAnalysisResult(); - - if (analysisResult instanceof JsAnalysisResult.RetryWithAdditionalRoots) { - environmentForJS.addKotlinSourceRoots(((JsAnalysisResult.RetryWithAdditionalRoots) analysisResult).getAdditionalKotlinRoots()); - } - } while(analysisResult instanceof JsAnalysisResult.RetryWithAdditionalRoots); - - if (!analysisResult.getShouldGenerateCode()) - return OK; - - assert analysisResult instanceof JsAnalysisResult : "analysisResult should be instance of JsAnalysisResult, but " + analysisResult; - JsAnalysisResult jsAnalysisResult = (JsAnalysisResult) analysisResult; - - File outputPrefixFile = null; - if (arguments.getOutputPrefix() != null) { - outputPrefixFile = new File(arguments.getOutputPrefix()); - if (!outputPrefixFile.exists()) { - messageCollector.report(ERROR, "Output prefix file '" + arguments.getOutputPrefix() + "' not found", null); - return ExitCode.COMPILATION_ERROR; - } - } - - File outputPostfixFile = null; - if (arguments.getOutputPostfix() != null) { - outputPostfixFile = new File(arguments.getOutputPostfix()); - if (!outputPostfixFile.exists()) { - messageCollector.report(ERROR, "Output postfix file '" + arguments.getOutputPostfix() + "' not found", null); - return ExitCode.COMPILATION_ERROR; - } - } - - File outputDir = outputFile.getParentFile(); - if (outputDir == null) { - outputDir = outputFile.getAbsoluteFile().getParentFile(); - } - try { - config.getConfiguration().put(JSConfigurationKeys.OUTPUT_DIR, outputDir.getCanonicalFile()); - } - catch (IOException e) { - messageCollector.report(ERROR, "Could not resolve output directory", null); - return ExitCode.COMPILATION_ERROR; - } - - if (config.getConfiguration().getBoolean(JSConfigurationKeys.SOURCE_MAP)) { - checkDuplicateSourceFileNames(messageCollector, sourcesFiles, config); - } - - MainCallParameters mainCallParameters = createMainCallParameters(arguments.getMain()); - TranslationResult translationResult; - - try { - translationResult = translate(reporter, sourcesFiles, jsAnalysisResult, mainCallParameters, config); - } - catch (Exception e) { - throw ExceptionUtilsKt.rethrow(e); - } - - ProgressIndicatorAndCompilationCanceledStatus.checkCanceled(); - - AnalyzerWithCompilerReport.Companion.reportDiagnostics(translationResult.getDiagnostics(), messageCollector, configuration.getBoolean(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME)); - - if (translationResult instanceof TranslationResult.Fail) return ExitCode.COMPILATION_ERROR; - - TranslationResult.SuccessBase successResult = (TranslationResult.SuccessBase) translationResult; - OutputFileCollection outputFiles = successResult.getOutputFiles(outputFile, outputPrefixFile, outputPostfixFile); - - if (outputFile.isDirectory()) { - messageCollector.report(ERROR, "Cannot open output file '" + outputFile.getPath() + "': is a directory", null); - return ExitCode.COMPILATION_ERROR; - } - - ProgressIndicatorAndCompilationCanceledStatus.checkCanceled(); - - OutputUtilsKt.writeAll(outputFiles, outputDir, messageCollector, - configuration.getBoolean(CommonConfigurationKeys.REPORT_OUTPUT_FILES)); - - return OK; - } - - private static void checkDuplicateSourceFileNames( - @NotNull MessageCollector log, - @NotNull List sourceFiles, - @NotNull JsConfig config - ) { - if (config.getSourceMapRoots().isEmpty()) return; - - SourceFilePathResolver pathResolver = SourceFilePathResolver.create(config); - Map pathMap = new HashMap<>(); - Set duplicatePaths = new HashSet<>(); - - try { - for (KtFile sourceFile : sourceFiles) { - String path = sourceFile.getVirtualFile().getPath(); - String relativePath = pathResolver.getPathRelativeToSourceRoots(new File(sourceFile.getVirtualFile().getPath())); - - String existingPath = pathMap.get(relativePath); - if (existingPath != null) { - if (duplicatePaths.add(relativePath)) { - log.report(WARNING, "There are files with same path '" + relativePath + "', relative to source roots: " + - "'" + path + "' and '" + existingPath + "'. " + - "This will likely cause problems with debugger", null); - } - } - else { - pathMap.put(relativePath, path); - } - } - } - catch (IOException e) { - log.report(ERROR, "IO error occurred validating source path:\n" + ExceptionUtil.getThrowableText(e), null); - } - } - - private static void reportCompiledSourcesList(@NotNull MessageCollector messageCollector, @NotNull List sourceFiles) { - Iterable fileNames = CollectionsKt.map(sourceFiles, file -> { - VirtualFile virtualFile = file.getVirtualFile(); - if (virtualFile != null) { - return MessageUtil.virtualFileToPath(virtualFile); - } - return file.getName() + " (no virtual file)"; - }); - messageCollector.report(LOGGING, "Compiling source files: " + StringsKt.join(fileNames, ", "), null); + messageCollector.report(ERROR, "Old Kotlin/JS compiler is no longer supported. Please migrate to the new JS IR backend", null); + return COMPILATION_ERROR; } @Override @@ -406,122 +121,6 @@ public class K2JSCompiler extends CLICompiler { if (K2JSCompilerArgumentsKt.isIrBackendEnabled(arguments)) { getIrCompiler().setupPlatformSpecificArgumentsAndServices(configuration, arguments, services); } - if (K2JSCompilerArgumentsKt.isPreIrBackendDisabled(arguments)) { - return; - } - - MessageCollector messageCollector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY); - - if (arguments.getTarget() != null) { - assert "v5".equals(arguments.getTarget()) : "Unsupported ECMA version: " + arguments.getTarget(); - } - configuration.put(JSConfigurationKeys.TARGET, EcmaVersion.defaultVersion()); - - if (arguments.getSourceMap()) { - configuration.put(JSConfigurationKeys.SOURCE_MAP, true); - if (arguments.getSourceMapPrefix() != null) { - configuration.put(JSConfigurationKeys.SOURCE_MAP_PREFIX, arguments.getSourceMapPrefix()); - } - - String sourceMapSourceRoots = arguments.getSourceMapBaseDirs(); - if (sourceMapSourceRoots == null && StringUtil.isNotEmpty(arguments.getSourceMapPrefix())) { - sourceMapSourceRoots = calculateSourceMapSourceRoot(messageCollector, arguments); - } - - if (sourceMapSourceRoots != null) { - List sourceMapSourceRootList = StringUtil.split(sourceMapSourceRoots, File.pathSeparator); - configuration.put(JSConfigurationKeys.SOURCE_MAP_SOURCE_ROOTS, sourceMapSourceRootList); - } - } - else { - if (arguments.getSourceMapPrefix() != null) { - messageCollector.report(WARNING, "source-map-prefix argument has no effect without source map", null); - } - if (arguments.getSourceMapBaseDirs() != null) { - messageCollector.report(WARNING, "source-map-source-root argument has no effect without source map", null); - } - } - if (arguments.getMetaInfo()) { - configuration.put(JSConfigurationKeys.META_INFO, true); - } - - configuration.put(JSConfigurationKeys.TYPED_ARRAYS_ENABLED, arguments.getTypedArrays()); - - configuration.put(JSConfigurationKeys.FRIEND_PATHS_DISABLED, arguments.getFriendModulesDisabled()); - - if (!arguments.getFriendModulesDisabled() && arguments.getFriendModules() != null) { - List friendPaths = ArraysKt.filterNot(arguments.getFriendModules().split(File.pathSeparator), String::isEmpty); - configuration.put(JSConfigurationKeys.FRIEND_PATHS, friendPaths); - } - - configuration.put(JSConfigurationKeys.METADATA_ONLY, arguments.getMetadataOnly()); - - String moduleKindName = arguments.getModuleKind(); - ModuleKind moduleKind = moduleKindName != null ? moduleKindMap.get(moduleKindName) : ModuleKind.PLAIN; - if (moduleKind == null) { - messageCollector.report( - ERROR, "Unknown module kind: " + moduleKindName + ". Valid values are: plain, amd, commonjs, umd", null - ); - moduleKind = ModuleKind.PLAIN; - } - configuration.put(JSConfigurationKeys.MODULE_KIND, moduleKind); - - IncrementalDataProvider incrementalDataProvider = services.get(IncrementalDataProvider.class); - if (incrementalDataProvider != null) { - configuration.put(JSConfigurationKeys.INCREMENTAL_DATA_PROVIDER, incrementalDataProvider); - } - - IncrementalResultsConsumer incrementalResultsConsumer = services.get(IncrementalResultsConsumer.class); - if (incrementalResultsConsumer != null) { - configuration.put(JSConfigurationKeys.INCREMENTAL_RESULTS_CONSUMER, incrementalResultsConsumer); - } - - LookupTracker lookupTracker = services.get(LookupTracker.class); - if (lookupTracker != null) { - configuration.put(CommonConfigurationKeys.LOOKUP_TRACKER, lookupTracker); - } - - ExpectActualTracker expectActualTracker = services.get(ExpectActualTracker.class); - if (expectActualTracker != null) { - configuration.put(CommonConfigurationKeys.EXPECT_ACTUAL_TRACKER, expectActualTracker); - } - - String sourceMapEmbedContentString = arguments.getSourceMapEmbedSources(); - SourceMapSourceEmbedding sourceMapContentEmbedding = sourceMapEmbedContentString != null ? - sourceMapContentEmbeddingMap.get(sourceMapEmbedContentString) : - SourceMapSourceEmbedding.INLINING; - if (sourceMapContentEmbedding == null) { - String message = "Unknown source map source embedding mode: " + sourceMapEmbedContentString + ". Valid values are: " + - StringUtil.join(sourceMapContentEmbeddingMap.keySet(), ", "); - messageCollector.report(ERROR, message, null); - sourceMapContentEmbedding = SourceMapSourceEmbedding.INLINING; - } - configuration.put(JSConfigurationKeys.SOURCE_MAP_EMBED_SOURCES, sourceMapContentEmbedding); - - if (!arguments.getSourceMap() && sourceMapEmbedContentString != null) { - messageCollector.report(WARNING, "source-map-embed-sources argument has no effect without source map", null); - } - } - - @NotNull - private static List configureLibraries( - @NotNull K2JSCompilerArguments arguments, - @Nullable KotlinPaths paths, - @NotNull MessageCollector messageCollector - ) { - List libraries = new SmartList<>(); - if (!arguments.getNoStdlib()) { - File stdlibJar = getLibraryFromHome( - paths, KotlinPaths::getJsStdLibKlibPath, PathUtil.JS_LIB_JAR_NAME, messageCollector, "'-no-stdlib'"); - if (stdlibJar != null) { - libraries.add(stdlibJar.getAbsolutePath()); - } - } - - if (arguments.getLibraries() != null) { - libraries.addAll(ArraysKt.filterNot(arguments.getLibraries().split(File.pathSeparator), String::isEmpty)); - } - return libraries; } @NotNull @@ -581,15 +180,6 @@ public class K2JSCompiler extends CLICompiler { return performanceManager; } - private static MainCallParameters createMainCallParameters(String main) { - if (K2JsArgumentConstants.NO_CALL.equals(main)) { - return MainCallParameters.noCall(); - } - else { - return MainCallParameters.mainWithoutArguments(); - } - } - @NotNull @Override public String executableScriptFileName() { diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt index 7cceda92faf..4f7d18d1154 100644 --- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt +++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt @@ -711,10 +711,6 @@ class K2JsIrCompiler : CLICompiler() { } } - if (arguments.metaInfo) { - configuration.put(JSConfigurationKeys.META_INFO, true) - } - configuration.put(JSConfigurationKeys.TYPED_ARRAYS_ENABLED, arguments.typedArrays) configuration.put(JSConfigurationKeys.FRIEND_PATHS_DISABLED, arguments.friendModulesDisabled) diff --git a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJsCompilerRunner.kt b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJsCompilerRunner.kt index 8a343fb6b07..9d2cccd9ae7 100644 --- a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJsCompilerRunner.kt +++ b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJsCompilerRunner.kt @@ -108,10 +108,7 @@ class IncrementalJsCompilerRunner( IncrementalJsCachesManager(icContext, if (!args.isIrBackendEnabled()) JsSerializerProtocol else KlibMetadataSerializerProtocol, cacheDirectory) override fun destinationDir(args: K2JSCompilerArguments): File { - return if (args.isIrBackendEnabled()) - File(args.outputDir!!) - else - File(args.outputFile!!).parentFile + return File(args.outputDir!!) } override fun calculateSourcesToCompile( diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index ad912c952b2..5812b78d6a6 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -6,8 +6,6 @@ where advanced options include: -Xenable-extension-functions-in-externals Enable extension function members in external interfaces. -Xfake-override-validator Enable the IR fake override validator. - -Xforce-deprecated-legacy-compiler-usage - This flag is used only for our inner infrastructure. It will soon be removed, so it's no longer safe to use. -Xfriend-modules= Paths to friend modules. -Xfriend-modules-disabled Disable internal declaration export. -Xgenerate-dts Generate a TypeScript declaration .d.ts file alongside the JS file. This is available only in the IR backend. @@ -43,7 +41,6 @@ where advanced options include: -Xir-safe-external-boolean Wrap access to external 'Boolean' properties with an explicit conversion to 'Boolean'. -Xir-safe-external-boolean-diagnostic={log|exception} Enable runtime diagnostics when accessing external 'Boolean' properties. - -Xmetadata-only Generate .meta.js and .kjsm files only. -Xoptimize-generated-js Perform additional optimizations on the generated JS code. -Xpartial-linkage-loglevel={info|warning|error} Define the compile-time log level for partial linkage. diff --git a/compiler/testData/cli/js/jsHelp.out b/compiler/testData/cli/js/jsHelp.out index dd4a61124a2..d0bc2335498 100644 --- a/compiler/testData/cli/js/jsHelp.out +++ b/compiler/testData/cli/js/jsHelp.out @@ -6,11 +6,8 @@ where possible options include: -module-kind {plain|amd|commonjs|umd|es} The kind of JS module generated by the compiler. -ir-output-name Base name of generated files. - -no-stdlib Don't automatically include the default Kotlin/JS stdlib in compilation dependencies. -ir-output-dir Destination for generated files. -output Destination *.js file for the compilation result. - -output-postfix Add the content of the specified file to the end of the output file. - -output-prefix Add the content of the specified file to the beginning of the output file. -source-map Generate a source map. -source-map-base-dirs Base directories for calculating relative paths to source files in the source map. -source-map-embed-sources {always|never|inlining} diff --git a/generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt b/generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt index ea0cdd32714..2950869e1a0 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt @@ -52,7 +52,7 @@ private fun generateRec( withPrinterToFile(destDir.resolve(klassName + "CopyGenerated.kt")) { println( """ - @file:Suppress("unused", "DuplicatedCode") + @file:Suppress("unused", "DuplicatedCode", "DEPRECATION") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt diff --git a/jps/jps-common/gen/org/jetbrains/kotlin/config/CompilerSettingsCopyGenerated.kt b/jps/jps-common/gen/org/jetbrains/kotlin/config/CompilerSettingsCopyGenerated.kt index 3976b678b41..51d42169db1 100644 --- a/jps/jps-common/gen/org/jetbrains/kotlin/config/CompilerSettingsCopyGenerated.kt +++ b/jps/jps-common/gen/org/jetbrains/kotlin/config/CompilerSettingsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode") +@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt diff --git a/jps/jps-common/gen/org/jetbrains/kotlin/config/JpsPluginSettingsCopyGenerated.kt b/jps/jps-common/gen/org/jetbrains/kotlin/config/JpsPluginSettingsCopyGenerated.kt index 890e1ef7c86..dd2f9df11fa 100644 --- a/jps/jps-common/gen/org/jetbrains/kotlin/config/JpsPluginSettingsCopyGenerated.kt +++ b/jps/jps-common/gen/org/jetbrains/kotlin/config/JpsPluginSettingsCopyGenerated.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused", "DuplicatedCode") +@file:Suppress("unused", "DuplicatedCode", "DEPRECATION") // DO NOT EDIT MANUALLY! // Generated by generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateCompilerArgumentsCopy.kt diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt b/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt index ebe97fedf6e..1a25cfe3a8b 100644 --- a/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt @@ -3,6 +3,8 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ +@file:Suppress("DEPRECATION") + package org.jetbrains.kotlin.config import com.intellij.openapi.util.io.FileUtilRt diff --git a/jps/jps-common/test/CompilerArgumentsContentProspectorTest.kt b/jps/jps-common/test/CompilerArgumentsContentProspectorTest.kt index 40db8612f34..cfa6c14a4ac 100644 --- a/jps/jps-common/test/CompilerArgumentsContentProspectorTest.kt +++ b/jps/jps-common/test/CompilerArgumentsContentProspectorTest.kt @@ -210,9 +210,7 @@ class CompilerArgumentsContentProspectorTest { K2MetadataCompilerArguments::refinesPaths ) private val k2JSCompilerArgumentsFlagProperties = commonCompilerArgumentsFlagProperties + listOf( - K2JSCompilerArguments::noStdlib, K2JSCompilerArguments::sourceMap, - K2JSCompilerArguments::metaInfo, K2JSCompilerArguments::irProduceKlibDir, K2JSCompilerArguments::irProduceKlibFile, K2JSCompilerArguments::irProduceJs, @@ -225,7 +223,6 @@ class CompilerArgumentsContentProspectorTest { K2JSCompilerArguments::useEsClasses, K2JSCompilerArguments::typedArrays, K2JSCompilerArguments::friendModulesDisabled, - K2JSCompilerArguments::metadataOnly, K2JSCompilerArguments::fakeOverrideValidator, K2JSCompilerArguments::wasm ) @@ -239,8 +236,6 @@ class CompilerArgumentsContentProspectorTest { K2JSCompilerArguments::target, K2JSCompilerArguments::moduleKind, K2JSCompilerArguments::main, - K2JSCompilerArguments::outputPrefix, - K2JSCompilerArguments::outputPostfix, K2JSCompilerArguments::irModuleName, K2JSCompilerArguments::includes, K2JSCompilerArguments::friendModules, diff --git a/libraries/tools/kotlin-gradle-plugin-api/api/kotlin-gradle-plugin-api.api b/libraries/tools/kotlin-gradle-plugin-api/api/kotlin-gradle-plugin-api.api index 1a81004f1ee..0bbfa22aa67 100644 --- a/libraries/tools/kotlin-gradle-plugin-api/api/kotlin-gradle-plugin-api.api +++ b/libraries/tools/kotlin-gradle-plugin-api/api/kotlin-gradle-plugin-api.api @@ -280,11 +280,8 @@ public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinHierarchyD public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptions : org/jetbrains/kotlin/gradle/dsl/KotlinCommonCompilerOptions { public abstract fun getFriendModulesDisabled ()Lorg/gradle/api/provider/Property; public abstract fun getMain ()Lorg/gradle/api/provider/Property; - public abstract fun getMetaInfo ()Lorg/gradle/api/provider/Property; public abstract fun getModuleKind ()Lorg/gradle/api/provider/Property; public abstract fun getModuleName ()Lorg/gradle/api/provider/Property; - public abstract fun getNoStdlib ()Lorg/gradle/api/provider/Property; - public abstract fun getOutputFile ()Lorg/gradle/api/provider/Property; public abstract fun getSourceMap ()Lorg/gradle/api/provider/Property; public abstract fun getSourceMapEmbedSources ()Lorg/gradle/api/provider/Property; public abstract fun getSourceMapNamesPolicy ()Lorg/gradle/api/provider/Property; @@ -325,12 +322,9 @@ public final class org/jetbrains/kotlin/gradle/dsl/KotlinJsDceOptions$DefaultImp public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinJsOptions : org/jetbrains/kotlin/gradle/dsl/KotlinCommonOptions { public abstract fun getFriendModulesDisabled ()Z public abstract fun getMain ()Ljava/lang/String; - public abstract fun getMetaInfo ()Z public abstract fun getModuleKind ()Ljava/lang/String; public abstract fun getModuleName ()Ljava/lang/String; - public abstract fun getNoStdlib ()Z public abstract fun getOptions ()Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptions; - public abstract fun getOutputFile ()Ljava/lang/String; public abstract fun getSourceMap ()Z public abstract fun getSourceMapEmbedSources ()Ljava/lang/String; public abstract fun getSourceMapNamesPolicy ()Ljava/lang/String; @@ -340,11 +334,8 @@ public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinJsOptions public abstract fun getUseEsClasses ()Z public abstract fun setFriendModulesDisabled (Z)V public abstract fun setMain (Ljava/lang/String;)V - public abstract fun setMetaInfo (Z)V public abstract fun setModuleKind (Ljava/lang/String;)V public abstract fun setModuleName (Ljava/lang/String;)V - public abstract fun setNoStdlib (Z)V - public abstract fun setOutputFile (Ljava/lang/String;)V public abstract fun setSourceMap (Z)V public abstract fun setSourceMapEmbedSources (Ljava/lang/String;)V public abstract fun setSourceMapNamesPolicy (Ljava/lang/String;)V @@ -361,11 +352,8 @@ public final class org/jetbrains/kotlin/gradle/dsl/KotlinJsOptions$DefaultImpls public static fun getFriendModulesDisabled (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Z public static fun getLanguageVersion (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Ljava/lang/String; public static fun getMain (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Ljava/lang/String; - public static fun getMetaInfo (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Z public static fun getModuleKind (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Ljava/lang/String; public static fun getModuleName (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Ljava/lang/String; - public static fun getNoStdlib (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Z - public static fun getOutputFile (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Ljava/lang/String; public static fun getSourceMap (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Z public static fun getSourceMapEmbedSources (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Ljava/lang/String; public static fun getSourceMapNamesPolicy (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;)Ljava/lang/String; @@ -382,11 +370,8 @@ public final class org/jetbrains/kotlin/gradle/dsl/KotlinJsOptions$DefaultImpls public static fun setFriendModulesDisabled (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Z)V public static fun setLanguageVersion (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Ljava/lang/String;)V public static fun setMain (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Ljava/lang/String;)V - public static fun setMetaInfo (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Z)V public static fun setModuleKind (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Ljava/lang/String;)V public static fun setModuleName (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Ljava/lang/String;)V - public static fun setNoStdlib (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Z)V - public static fun setOutputFile (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Ljava/lang/String;)V public static fun setSourceMap (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Z)V public static fun setSourceMapEmbedSources (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Ljava/lang/String;)V public static fun setSourceMapNamesPolicy (Lorg/jetbrains/kotlin/gradle/dsl/KotlinJsOptions;Ljava/lang/String;)V diff --git a/libraries/tools/kotlin-gradle-plugin-api/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptions.kt b/libraries/tools/kotlin-gradle-plugin-api/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptions.kt index 759c77151fc..4cd9a20726e 100644 --- a/libraries/tools/kotlin-gradle-plugin-api/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptions.kt +++ b/libraries/tools/kotlin-gradle-plugin-api/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptions.kt @@ -28,14 +28,6 @@ interface KotlinJsCompilerOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommon @get:org.gradle.api.tasks.Input val main: org.gradle.api.provider.Property - /** - * Generate .meta.js and .kjsm files with metadata. Use this to create a library. - * - * Default value: true - */ - @get:org.gradle.api.tasks.Input - val metaInfo: org.gradle.api.provider.Property - /** * The kind of JS module generated by the compiler. * @@ -55,23 +47,6 @@ interface KotlinJsCompilerOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommon @get:org.gradle.api.tasks.Input val moduleName: org.gradle.api.provider.Property - /** - * Don't automatically include the default Kotlin/JS stdlib in compilation dependencies. - * - * Default value: true - */ - @get:org.gradle.api.tasks.Input - val noStdlib: org.gradle.api.provider.Property - - /** - * Destination *.js file for the compilation result. - * - * Default value: null - */ - @Deprecated(message = "Only for legacy backend. For IR backend please use task.destinationDirectory and moduleName", level = DeprecationLevel.WARNING) - @get:org.gradle.api.tasks.Internal - val outputFile: org.gradle.api.provider.Property - /** * Generate a source map. * diff --git a/libraries/tools/kotlin-gradle-plugin-api/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJsOptions.kt b/libraries/tools/kotlin-gradle-plugin-api/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJsOptions.kt index 2f1aeab7a4d..3acd780f9ce 100644 --- a/libraries/tools/kotlin-gradle-plugin-api/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJsOptions.kt +++ b/libraries/tools/kotlin-gradle-plugin-api/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJsOptions.kt @@ -38,15 +38,6 @@ interface KotlinJsOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions get() = options.main.get().mainKotlinOption set(value) = options.main.set(value.mainCompilerOption) - /** - * Generate .meta.js and .kjsm files with metadata. Use this to create a library. - * - * Default value: true - */ - var metaInfo: kotlin.Boolean - get() = options.metaInfo.get() - set(value) = options.metaInfo.set(value) - private val kotlin.String.moduleKindCompilerOption get() = org.jetbrains.kotlin.gradle.dsl.JsModuleKind.fromKind(this) private val org.jetbrains.kotlin.gradle.dsl.JsModuleKind.moduleKindKotlinOption get() = this.kind @@ -71,25 +62,6 @@ interface KotlinJsOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions get() = options.moduleName.orNull set(value) = options.moduleName.set(value) - /** - * Don't automatically include the default Kotlin/JS stdlib in compilation dependencies. - * - * Default value: true - */ - var noStdlib: kotlin.Boolean - get() = options.noStdlib.get() - set(value) = options.noStdlib.set(value) - - /** - * Destination *.js file for the compilation result. - * - * Default value: null - */ - @Deprecated(message = "Only for legacy backend. For IR backend please use task.destinationDirectory and moduleName", level = DeprecationLevel.WARNING) - var outputFile: kotlin.String? - get() = options.outputFile.orNull - set(value) = options.outputFile.set(value) - /** * Generate a source map. * diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptionsDefault.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptionsDefault.kt index 25c41e616d3..3d0c9b986eb 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptionsDefault.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptionsDefault.kt @@ -15,22 +15,12 @@ internal abstract class KotlinJsCompilerOptionsDefault @javax.inject.Inject cons override val main: org.gradle.api.provider.Property = objectFactory.property(org.jetbrains.kotlin.gradle.dsl.JsMainFunctionExecutionMode::class.java).convention(org.jetbrains.kotlin.gradle.dsl.JsMainFunctionExecutionMode.CALL) - override val metaInfo: org.gradle.api.provider.Property = - objectFactory.property(kotlin.Boolean::class.java).convention(true) - override val moduleKind: org.gradle.api.provider.Property = objectFactory.property(org.jetbrains.kotlin.gradle.dsl.JsModuleKind::class.java).convention(org.jetbrains.kotlin.gradle.dsl.JsModuleKind.MODULE_PLAIN) override val moduleName: org.gradle.api.provider.Property = objectFactory.property(kotlin.String::class.java) - override val noStdlib: org.gradle.api.provider.Property = - objectFactory.property(kotlin.Boolean::class.java).convention(true) - - @Deprecated(message = "Only for legacy backend. For IR backend please use task.destinationDirectory and moduleName", level = DeprecationLevel.WARNING) - override val outputFile: org.gradle.api.provider.Property = - objectFactory.property(kotlin.String::class.java) - override val sourceMap: org.gradle.api.provider.Property = objectFactory.property(kotlin.Boolean::class.java).convention(false) diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptionsHelper.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptionsHelper.kt index 538516514c2..a1c7a13357e 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptionsHelper.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptionsHelper.kt @@ -14,11 +14,8 @@ internal object KotlinJsCompilerOptionsHelper { org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptionsHelper.fillCompilerArguments(from, args) args.friendModulesDisabled = from.friendModulesDisabled.get() args.main = from.main.get().mode - args.metaInfo = from.metaInfo.get() args.moduleKind = from.moduleKind.get().kind args.moduleName = from.moduleName.orNull - args.noStdlib = from.noStdlib.get() - args.outputFile = from.outputFile.orNull args.sourceMap = from.sourceMap.get() args.sourceMapEmbedSources = from.sourceMapEmbedSources.orNull?.mode args.sourceMapNamesPolicy = from.sourceMapNamesPolicy.orNull?.policy @@ -35,11 +32,8 @@ internal object KotlinJsCompilerOptionsHelper { org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptionsHelper.syncOptionsAsConvention(from, into) into.friendModulesDisabled.convention(from.friendModulesDisabled) into.main.convention(from.main) - into.metaInfo.convention(from.metaInfo) into.moduleKind.convention(from.moduleKind) into.moduleName.convention(from.moduleName) - into.noStdlib.convention(from.noStdlib) - into.outputFile.convention(from.outputFile) into.sourceMap.convention(from.sourceMap) into.sourceMapEmbedSources.convention(from.sourceMapEmbedSources) into.sourceMapNamesPolicy.convention(from.sourceMapNamesPolicy) diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinSourceSetProcessor.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinSourceSetProcessor.kt index b3e435b4db2..a55a5d4119d 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinSourceSetProcessor.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinSourceSetProcessor.kt @@ -58,23 +58,10 @@ internal abstract class KotlinSourceSetProcessor>( val kotlinSourceDirectorySet = compilationInfo.tcs.compilation.defaultSourceSet.kotlin kotlinSourceDirectorySet.destinationDirectory.value(defaultKotlinDestinationDir) task.configure { - if (it is Kotlin2JsCompile) { - it.defaultDestinationDirectory.convention(kotlinSourceDirectorySet.destinationDirectory) - } else { - it.destinationDirectory.convention(kotlinSourceDirectorySet.destinationDirectory) - } + it.destinationDirectory.convention(kotlinSourceDirectorySet.destinationDirectory) } compilationInfo.classesDirs.from(kotlinSourceDirectorySet.destinationDirectory).builtBy(task) - if (compilationInfo.tcs.compilation.platformType == KotlinPlatformType.js) { - @Suppress("UNCHECKED_CAST") - kotlinSourceDirectorySet.compiledBy( - task as TaskProvider, - Kotlin2JsCompile::defaultDestinationDirectory - ) - (kotlinSourceDirectorySet.classesDirectory as Property).set(task.flatMap { it.destinationDirectory }) - } else { - kotlinSourceDirectorySet.compiledBy(task, AbstractKotlinCompile<*>::destinationDirectory) - } + kotlinSourceDirectorySet.compiledBy(task, AbstractKotlinCompile<*>::destinationDirectory) if (compilationInfo.isMain) { project.tasks.named( compilationInfo.tcs.compilation.target.artifactsTaskName, @@ -133,11 +120,7 @@ internal abstract class KotlinSourceSetProcessor>( protected fun applyStandardTaskConfiguration(taskConfiguration: AbstractKotlinCompileConfig<*>) { taskConfiguration.configureTask { it.description = taskDescription - if (it is Kotlin2JsCompile) { - it.defaultDestinationDirectory.convention(defaultKotlinDestinationDir) - } else { - it.destinationDirectory.convention(defaultKotlinDestinationDir) - } + it.destinationDirectory.convention(defaultKotlinDestinationDir) it.libraries.from({ compilationInfo.compileDependencyFiles }) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/statistics/FusMetrics.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/statistics/FusMetrics.kt index 698a1782f27..09651b9aec3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/statistics/FusMetrics.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/statistics/FusMetrics.kt @@ -87,10 +87,9 @@ internal object CompilerArgumentMetrics : FusMetrics { is K2JSCompilerArguments -> { val args = K2JSCompilerArguments() parseCommandLineArguments(argsArray.toList(), args) - if (!args.isPreIrBackendDisabled() || args.irProduceJs) { - metricsConsumer.report(BooleanMetrics.JS_SOURCE_MAP, args.sourceMap) - } + if (args.irProduceJs) { + metricsConsumer.report(BooleanMetrics.JS_SOURCE_MAP, args.sourceMap) metricsConsumer.report(StringMetrics.JS_PROPERTY_LAZY_INITIALIZATION, args.irPropertyLazyInitialization.toString()) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/configuration/Kotlin2JsCompileConfig.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/configuration/Kotlin2JsCompileConfig.kt index 5cbca410615..855b81336a6 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/configuration/Kotlin2JsCompileConfig.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/configuration/Kotlin2JsCompileConfig.kt @@ -15,7 +15,6 @@ import org.jetbrains.kotlin.gradle.targets.js.ir.* import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile import org.jetbrains.kotlin.gradle.utils.klibModuleName import org.jetbrains.kotlin.gradle.utils.providerWithLazyConvention -import java.io.File internal typealias Kotlin2JsCompileConfig = BaseKotlin2JsCompileConfig @@ -37,26 +36,6 @@ internal open class BaseKotlin2JsCompileConfig( configureAdditionalFreeCompilerArguments(task, compilation) - task.destinationDirectory - .convention( - project.objects.directoryProperty().fileProvider( - task.defaultDestinationDirectory.map { - val freeArgs = task.enhancedFreeCompilerArgs.get() - @Suppress("DEPRECATION") - if (task.compilerOptions.outputFile.orNull != null) { - if (freeArgs.contains(PRODUCE_UNZIPPED_KLIB)) { - val file = File(task.compilerOptions.outputFile.get()) - if (file.extension == "") file else file.parentFile - } else { - File(task.compilerOptions.outputFile.get()).parentFile - } - } else { - it.asFile - } - } - ) - ) - task.libraryFilterCacheService.value(libraryFilterCachingService).disallowChanges() task.incrementalModuleInfoProvider.value(incrementalModuleInfoProvider).disallowChanges() }