From fb66764c4d7d4216e92cb959a4039c28308d6d08 Mon Sep 17 00:00:00 2001 From: Sebastian Sellmair Date: Mon, 3 Apr 2023 09:29:25 +0200 Subject: [PATCH] [CLI] K2JVMCompilerArguments: Model modulePath as Array to allow interning individual file-path arguments on the IDE KTIJ-24976 --- .../arguments/K2JVMCompilerArgumentsCopyGenerated.kt | 2 +- .../cli/common/arguments/K2JVMCompilerArguments.kt | 9 +++++++-- .../cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt | 2 +- .../kotlin/fir/AbstractFrontendModularizedTest.kt | 2 +- .../org/jetbrains/kotlin/maven/K2JVMCompileMojo.java | 5 +++-- 5 files changed, 13 insertions(+), 7 deletions(-) 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 33ece639ca0..34ef3ee3503 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 @@ -33,7 +33,7 @@ fun copyK2JVMCompilerArguments(from: K2JVMCompilerArguments, to: K2JVMCompilerAr to.friendPaths = from.friendPaths?.copyOf() to.includeRuntime = from.includeRuntime to.inheritMultifileParts = from.inheritMultifileParts - to.javaModulePath = from.javaModulePath + to.javaModulePath = from.javaModulePath?.copyOf() to.javaPackagePrefix = from.javaPackagePrefix to.javaParameters = from.javaParameters to.javaSourceRoots = from.javaSourceRoots?.copyOf() diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt index fbcd3cb3bda..2eac672943c 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt @@ -210,8 +210,13 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { field = value } - @Argument(value = "-Xmodule-path", valueDescription = "", description = "Paths where to find Java 9+ modules") - var javaModulePath: String? = null + @Argument( + value = "-Xmodule-path", + valueDescription = "", + description = "Paths where to find Java 9+ modules", + delimiter = Argument.Delimiters.pathSeparator + ) + var javaModulePath: Array? = null set(value) { checkFrozen() field = if (value.isNullOrEmpty()) null else value diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt index d316deff58c..00575193808 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt @@ -173,7 +173,7 @@ fun CompilerConfiguration.configureJdkHome(arguments: K2JVMCompilerArguments): B } fun CompilerConfiguration.configureJavaModulesContentRoots(arguments: K2JVMCompilerArguments) { - for (modularRoot in arguments.javaModulePath?.split(File.pathSeparatorChar).orEmpty()) { + for (modularRoot in arguments.javaModulePath.orEmpty()) { add(CLIConfigurationKeys.CONTENT_ROOTS, JvmModulePathRoot(File(modularRoot))) } } diff --git a/compiler/fir/modularized-tests/tests/org/jetbrains/kotlin/fir/AbstractFrontendModularizedTest.kt b/compiler/fir/modularized-tests/tests/org/jetbrains/kotlin/fir/AbstractFrontendModularizedTest.kt index 5397dd8e6f1..f5d8fd94eaf 100644 --- a/compiler/fir/modularized-tests/tests/org/jetbrains/kotlin/fir/AbstractFrontendModularizedTest.kt +++ b/compiler/fir/modularized-tests/tests/org/jetbrains/kotlin/fir/AbstractFrontendModularizedTest.kt @@ -77,7 +77,7 @@ abstract class AbstractFrontendModularizedTest : AbstractModularizedTest() { if (originalArguments != null) { configuration.put(JVMConfigurationKeys.NO_JDK, originalArguments.noJdk) - for (modularRoot in originalArguments.javaModulePath?.split(File.pathSeparatorChar).orEmpty()) { + for (modularRoot in originalArguments.javaModulePath.orEmpty()) { configuration.add(CLIConfigurationKeys.CONTENT_ROOTS, JvmModulePathRoot(modularRoot.fixPath())) } diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JVMCompileMojo.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JVMCompileMojo.java index 7b16aee52a1..653ff91a951 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JVMCompileMojo.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JVMCompileMojo.java @@ -165,13 +165,14 @@ public class K2JVMCompileMojo extends KotlinCompileMojoBase