Use kotlin home for automatic loading of the scripting plugin
This commit is contained in:
@@ -69,7 +69,7 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
|||||||
|
|
||||||
configuration.put(JVMConfigurationKeys.DISABLE_STANDARD_SCRIPT_DEFINITION, arguments.disableStandardScript)
|
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
|
if (pluginLoadResult != ExitCode.OK) return pluginLoadResult
|
||||||
|
|
||||||
val moduleName = arguments.moduleName ?: JvmProtoBufUtil.DEFAULT_MODULE_NAME
|
val moduleName = arguments.moduleName ?: JvmProtoBufUtil.DEFAULT_MODULE_NAME
|
||||||
@@ -197,7 +197,7 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadPlugins(arguments: K2JVMCompilerArguments, configuration: CompilerConfiguration): ExitCode {
|
private fun loadPlugins(paths: KotlinPaths?, arguments: K2JVMCompilerArguments, configuration: CompilerConfiguration): ExitCode {
|
||||||
var pluginClasspaths: Iterable<String> = arguments.pluginClasspaths?.asIterable() ?: emptyList()
|
var pluginClasspaths: Iterable<String> = arguments.pluginClasspaths?.asIterable() ?: emptyList()
|
||||||
val pluginOptions = arguments.pluginOptions?.toMutableList() ?: ArrayList()
|
val pluginOptions = arguments.pluginOptions?.toMutableList() ?: ArrayList()
|
||||||
|
|
||||||
@@ -213,7 +213,8 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
|||||||
// if scripting plugin is not enabled explicitly (probably from another path) and not in the classpath already,
|
// if scripting plugin is not enabled explicitly (probably from another path) and not in the classpath already,
|
||||||
// try to find and enable it implicitly
|
// try to find and enable it implicitly
|
||||||
if (!explicitOrLoadedScriptingPlugin) {
|
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) =
|
val (jars, missingJars) =
|
||||||
PathUtil.KOTLIN_SCRIPTING_PLUGIN_CLASSPATH_JARS.mapNotNull { File(libPath, it) }.partition { it.exists() }
|
PathUtil.KOTLIN_SCRIPTING_PLUGIN_CLASSPATH_JARS.mapNotNull { File(libPath, it) }.partition { it.exists() }
|
||||||
if (missingJars.isEmpty()) {
|
if (missingJars.isEmpty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user