From 2be7116b0ba92d311b559678211e274d041fa049 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 28 Nov 2017 18:52:22 +0100 Subject: [PATCH] Deduplicate classpath roots in compiler when -Xbuild-file is used In kotlin-gradle-plugin, the compiler is invoked with a K2JVMCompilerArguments instance where both the classpath is set, and the buildFile is used (containing the same classpath entries in XML). Previously, the compiler concatenated those two classpaths, which resulted in duplicated entries, which could slow down compilation. Now, if buildFile is used, the classpath passed explicitly is ignored (exactly as, for example, destination ("-d"), which is also stored in the XML build file). No test added because there doesn't seem to be any change in user-visible behavior --- .../jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt index 91fda3da3a9..f0ae761ed17 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -91,17 +91,19 @@ class K2JVMCompiler : CLICompiler() { } } - configureContentRoots(paths, arguments, configuration) - configuration.put(CommonConfigurationKeys.MODULE_NAME, arguments.moduleName ?: JvmAbi.DEFAULT_MODULE_NAME) - if (arguments.buildFile == null && arguments.freeArgs.isEmpty() && !arguments.version) { - if (arguments.script) { - messageCollector.report(ERROR, "Specify script source path to evaluate") - return COMPILATION_ERROR + if (arguments.buildFile == null) { + configureContentRoots(paths, arguments, configuration) + + if (arguments.freeArgs.isEmpty() && !arguments.version) { + if (arguments.script) { + messageCollector.report(ERROR, "Specify script source path to evaluate") + return COMPILATION_ERROR + } + ReplFromTerminal.run(rootDisposable, configuration) + return ExitCode.OK } - ReplFromTerminal.run(rootDisposable, configuration) - return ExitCode.OK } if (arguments.includeRuntime) {