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 34ef3ee3503..9fcb5308036 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 @@ -17,7 +17,7 @@ fun copyK2JVMCompilerArguments(from: K2JVMCompilerArguments, to: K2JVMCompilerAr to.assertionsMode = from.assertionsMode to.backendThreads = from.backendThreads to.buildFile = from.buildFile - to.classpath = from.classpath?.copyOf() + to.classpath = from.classpath to.compileJava = from.compileJava to.declarationsOutputPath = from.declarationsOutputPath to.defaultScriptExtension = from.defaultScriptExtension @@ -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?.copyOf() + to.javaModulePath = from.javaModulePath 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 2eac672943c..6eec916e764 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 @@ -26,10 +26,9 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { value = "-classpath", shortName = "-cp", valueDescription = "", - description = "List of directories and JAR/ZIP archives to search for user class files", - delimiter = Argument.Delimiters.pathSeparator + description = "List of directories and JAR/ZIP archives to search for user class files" ) - var classpath: Array? = null + var classpath: String? = null set(value) { checkFrozen() field = if (value.isNullOrEmpty()) null else value @@ -210,13 +209,8 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { field = value } - @Argument( - value = "-Xmodule-path", - valueDescription = "", - description = "Paths where to find Java 9+ modules", - delimiter = Argument.Delimiters.pathSeparator - ) - var javaModulePath: Array? = null + @Argument(value = "-Xmodule-path", valueDescription = "", description = "Paths where to find Java 9+ modules") + var javaModulePath: String? = null set(value) { checkFrozen() field = if (value.isNullOrEmpty()) null else value diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/cliCompilerUtils.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/cliCompilerUtils.kt index c7de0dea25e..bcdfa4924ca 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/cliCompilerUtils.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/cliCompilerUtils.kt @@ -174,7 +174,7 @@ fun writeOutputsIfNeeded( fun ModuleBuilder.configureFromArgs(args: K2JVMCompilerArguments) { args.friendPaths?.forEach { addFriendDir(it) } - args.classpath?.forEach { addClasspathEntry(it) } + args.classpath?.split(File.pathSeparator)?.forEach { addClasspathEntry(it) } args.javaSourceRoots?.forEach { addJavaSourceRoot(JavaRootPath(it, args.javaPackagePrefix)) } 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 27ac7f59b1a..8147c172343 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt @@ -177,13 +177,13 @@ fun CompilerConfiguration.configureJdkHomeFromSystemProperty() { } fun CompilerConfiguration.configureJavaModulesContentRoots(arguments: K2JVMCompilerArguments) { - for (modularRoot in arguments.javaModulePath.orEmpty()) { + for (modularRoot in arguments.javaModulePath?.split(File.pathSeparatorChar).orEmpty()) { add(CLIConfigurationKeys.CONTENT_ROOTS, JvmModulePathRoot(File(modularRoot))) } } fun CompilerConfiguration.configureContentRootsFromClassPath(arguments: K2JVMCompilerArguments) { - for (path in arguments.classpath.orEmpty()) { + for (path in arguments.classpath?.split(File.pathSeparatorChar).orEmpty()) { add(CLIConfigurationKeys.CONTENT_ROOTS, JvmClasspathRoot(File(path))) } } 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 f5d8fd94eaf..5397dd8e6f1 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.orEmpty()) { + for (modularRoot in originalArguments.javaModulePath?.split(File.pathSeparatorChar).orEmpty()) { configuration.add(CLIConfigurationKeys.CONTENT_ROOTS, JvmModulePathRoot(modularRoot.fixPath())) } diff --git a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalFirJvmCompilerRunner.kt b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalFirJvmCompilerRunner.kt index e27d6978eaf..9953d88ea9c 100644 --- a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalFirJvmCompilerRunner.kt +++ b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalFirJvmCompilerRunner.kt @@ -342,7 +342,7 @@ fun CompilerConfiguration.configureBaseRoots(args: K2JVMCompilerArguments) { } } - args.classpath?.forEach { classpathRoot -> + args.classpath?.split(File.pathSeparator)?.forEach { classpathRoot -> add( CLIConfigurationKeys.CONTENT_ROOTS, if (isJava9Module) JvmModulePathRoot(File(classpathRoot)) else JvmClasspathRoot(File(classpathRoot)) diff --git a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt index a04f7ee898f..9545de3cee6 100644 --- a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt +++ b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt @@ -550,7 +550,7 @@ var K2JVMCompilerArguments.destinationAsFile: File } var K2JVMCompilerArguments.classpathAsList: List - get() = classpath.orEmpty().map(::File) + get() = classpath.orEmpty().split(File.pathSeparator).map(::File) set(value) { - classpath = value.map { it.path }.toTypedArray() + classpath = value.joinToString(separator = File.pathSeparator, transform = { it.path }) } diff --git a/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/AbstractIncrementalJvmCompilerRunnerTest.kt b/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/AbstractIncrementalJvmCompilerRunnerTest.kt index 4f3f02314da..b93cda46c1f 100644 --- a/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/AbstractIncrementalJvmCompilerRunnerTest.kt +++ b/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/AbstractIncrementalJvmCompilerRunnerTest.kt @@ -48,14 +48,14 @@ abstract class AbstractIncrementalJvmCompilerRunnerTest : AbstractIncrementalCom } if (javaSources.isEmpty()) return TestCompilationResult(ExitCode.OK, emptyList(), emptyList()) - val javaClasspath = compileClasspath + kotlinClassesPath + val javaClasspath = compileClasspath + File.pathSeparator + kotlinClassesPath val javaDestinationDir = File(workingDir, "java-classes").apply { if (exists()) { deleteRecursively() } mkdirs() } - val args = arrayOf("-cp", javaClasspath.joinToString(File.pathSeparator), + val args = arrayOf("-cp", javaClasspath, "-d", javaDestinationDir.canonicalPath, *javaSources.map { it.canonicalPath }.toTypedArray() ) @@ -73,12 +73,12 @@ abstract class AbstractIncrementalJvmCompilerRunnerTest : AbstractIncrementalCom K2JVMCompilerArguments().apply { moduleName = testDir.name destination = destinationDir.path - classpath = compileClasspath.toTypedArray() + classpath = compileClasspath } private val compileClasspath = listOf( kotlinStdlibJvm, KtTestUtil.getAnnotationsJar() - ).map { it.canonicalPath } + ).joinToString(File.pathSeparator) { it.canonicalPath } } diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt index e2ec4cbc1b8..8fa5d30940d 100644 --- a/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt @@ -181,7 +181,7 @@ class KotlinFacetSettings { if (compilerSettings != null) { parseCommandLineArguments(compilerSettings.additionalArgumentsAsList, this) } - if (this is K2JVMCompilerArguments) this.classpath = null + if (this is K2JVMCompilerArguments) this.classpath = "" } } else null } 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 0cf68c50015..f49de73af15 100644 --- a/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt @@ -230,7 +230,7 @@ fun CommonCompilerArguments.convertPathsToSystemIndependent() { when (this) { is K2JVMCompilerArguments -> { destination = destination?.let(FileUtilRt::toSystemIndependentName) - classpath?.forEachIndexed { index, s -> classpath!![index] = FileUtilRt.toSystemIndependentName(s) } + classpath = classpath?.let(FileUtilRt::toSystemIndependentName) jdkHome = jdkHome?.let(FileUtilRt::toSystemIndependentName) kotlinHome = kotlinHome?.let(FileUtilRt::toSystemIndependentName) friendPaths?.forEachIndexed { index, s -> friendPaths!![index] = FileUtilRt.toSystemIndependentName(s) } diff --git a/jps/jps-common/test/CompilerArgumentsSerializationTest.kt b/jps/jps-common/test/CompilerArgumentsSerializationTest.kt index 7a88a5034ce..84e970ff112 100644 --- a/jps/jps-common/test/CompilerArgumentsSerializationTest.kt +++ b/jps/jps-common/test/CompilerArgumentsSerializationTest.kt @@ -34,7 +34,7 @@ class CompilerArgumentsSerializationTest { @Test fun testLongClasspathArgumentJVM() { doSerializeDeserializeAndCompareTest { - classpath = generateSequence { generateRandomString(50) }.take(10).toList().toTypedArray() + classpath = generateSequence { generateRandomString(50) }.take(10).toList().joinToString(File.pathSeparator) } } @@ -184,4 +184,4 @@ class CompilerArgumentsSerializationTest { .map(charPool::get) .joinToString("") } -} \ No newline at end of file +} 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 2d26715b33e..b1ec159d09e 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 @@ -12,7 +12,6 @@ import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.vfs.StandardFileSystems import com.intellij.testFramework.LightVirtualFile import com.intellij.testFramework.UsefulTestCase -import com.intellij.util.io.Decompressor import com.intellij.util.io.URLUtil import com.intellij.util.io.ZipUtil import org.jetbrains.jps.ModuleChunk @@ -958,7 +957,7 @@ open class KotlinJpsBuildTest : KotlinJpsBuildTestBase() { Files.copy(libraryJar.toPath(), module1Lib.toPath(), StandardCopyOption.REPLACE_EXISTING) assert(module1Lib.exists()) - (facet.compilerArguments as K2JVMCompilerArguments).classpath = arrayOf(module1Lib.path) + (facet.compilerArguments as K2JVMCompilerArguments).classpath = module1Lib.path it.container.setChild( JpsKotlinFacetModuleExtension.KIND, 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 653ff91a951..80d6abdb5f6 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,14 +165,13 @@ public class K2JVMCompileMojo extends KotlinCompileMojoBase filteredClasspath = new ArrayList<>(); - for (String path : classpath) { + for (String path : classpath.split(File.pathSeparator)) { if (!classesDir.equals(new File(path))) { filteredClasspath.add(path); } } - arguments.setClasspath(filteredClasspath.toArray(new String[0])); + arguments.setClasspath(StringUtil.join(filteredClasspath, File.pathSeparator)); } IncrementalJvmCompilerRunnerKt.makeIncrementally(cachesDir, sourceRoots, arguments, messageCollector, icReporter); diff --git a/plugins/fir-plugin-prototype/fir-plugin-ic-test/tests/org/jetbrains/kotlin/incremental/AbstractIncrementalFirJvmCompilerRunnerTest.kt b/plugins/fir-plugin-prototype/fir-plugin-ic-test/tests/org/jetbrains/kotlin/incremental/AbstractIncrementalFirJvmCompilerRunnerTest.kt index 160a4f1e720..e2d5dd8f0c6 100644 --- a/plugins/fir-plugin-prototype/fir-plugin-ic-test/tests/org/jetbrains/kotlin/incremental/AbstractIncrementalFirJvmCompilerRunnerTest.kt +++ b/plugins/fir-plugin-prototype/fir-plugin-ic-test/tests/org/jetbrains/kotlin/incremental/AbstractIncrementalFirJvmCompilerRunnerTest.kt @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments import org.jetbrains.kotlin.incremental.testingUtils.BuildLogFinder import org.junit.jupiter.api.fail import java.io.File -import java.io.FilenameFilter abstract class AbstractIncrementalFirJvmWithPluginCompilerRunnerTest : AbstractIncrementalFirJvmCompilerRunnerTest() { companion object { @@ -35,7 +34,7 @@ abstract class AbstractIncrementalFirJvmWithPluginCompilerRunnerTest : AbstractI val annotationsJar = findJar(ANNOTATIONS_JAR_DIR, ANNOTATIONS_JAR_NAME, ":plugins:fir-plugin-prototype:plugin-annotations:jar") val pluginJar = findJar(PLUGIN_JAR_DIR, PLUGIN_JAR_NAME, ":plugins:fir-plugin-prototype:jar") - classpath = classpath?.plus(annotationsJar) + classpath += "${File.pathSeparator}$annotationsJar" pluginClasspaths = arrayOf(pluginJar) } diff --git a/plugins/jvm-abi-gen/test/org/jetbrains/kotlin/jvm/abi/BaseJvmAbiTest.kt b/plugins/jvm-abi-gen/test/org/jetbrains/kotlin/jvm/abi/BaseJvmAbiTest.kt index 59b7ca0b942..f25f4750b34 100644 --- a/plugins/jvm-abi-gen/test/org/jetbrains/kotlin/jvm/abi/BaseJvmAbiTest.kt +++ b/plugins/jvm-abi-gen/test/org/jetbrains/kotlin/jvm/abi/BaseJvmAbiTest.kt @@ -74,7 +74,7 @@ abstract class BaseJvmAbiTest : TestCase() { val compiler = K2JVMCompiler() val args = compiler.createArguments().apply { freeArgs = listOf(compilation.srcDir.canonicalPath) - classpath = (abiDependencies + kotlinJvmStdlib).map { it.canonicalPath }.toTypedArray() + classpath = (abiDependencies + kotlinJvmStdlib).joinToString(File.pathSeparator) { it.canonicalPath } pluginClasspaths = arrayOf(abiPluginJar.canonicalPath) pluginOptions = listOfNotNull( abiOption(JvmAbiCommandLineProcessor.OUTPUT_PATH_OPTION.optionName, compilation.abiDir.canonicalPath),