From 1ab255eafb8d0ef1dbcee15f71f3450ad7bbfc08 Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Tue, 2 Jul 2019 15:52:25 +0200 Subject: [PATCH] Use kotlin home for automatic loading of the scripting plugin --- .../cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 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 266e5dd6386..66312628ee9 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -69,7 +69,7 @@ class K2JVMCompiler : CLICompiler() { configuration.put(JVMConfigurationKeys.DISABLE_STANDARD_SCRIPT_DEFINITION, arguments.disableStandardScript) - val pluginLoadResult = loadPlugins(arguments, configuration) + val pluginLoadResult = loadPlugins(paths, arguments, configuration) if (pluginLoadResult != ExitCode.OK) return pluginLoadResult val moduleName = arguments.moduleName ?: JvmProtoBufUtil.DEFAULT_MODULE_NAME @@ -197,7 +197,7 @@ class K2JVMCompiler : CLICompiler() { } } - private fun loadPlugins(arguments: K2JVMCompilerArguments, configuration: CompilerConfiguration): ExitCode { + private fun loadPlugins(paths: KotlinPaths?, arguments: K2JVMCompilerArguments, configuration: CompilerConfiguration): ExitCode { var pluginClasspaths: Iterable = arguments.pluginClasspaths?.asIterable() ?: emptyList() val pluginOptions = arguments.pluginOptions?.toMutableList() ?: ArrayList() @@ -213,7 +213,8 @@ class K2JVMCompiler : CLICompiler() { // if scripting plugin is not enabled explicitly (probably from another path) and not in the classpath already, // try to find and enable it implicitly if (!explicitOrLoadedScriptingPlugin) { - val libPath = PathUtil.kotlinPathsForCompiler.libPath.takeIf { it.exists() && it.isDirectory } ?: File(".") + val kotlinPaths = paths ?: PathUtil.kotlinPathsForCompiler + val libPath = kotlinPaths.libPath.takeIf { it.exists() && it.isDirectory } ?: File(".") val (jars, missingJars) = PathUtil.KOTLIN_SCRIPTING_PLUGIN_CLASSPATH_JARS.mapNotNull { File(libPath, it) }.partition { it.exists() } if (missingJars.isEmpty()) {