Fix order of jars for the scripting plugin:

if gradle project is being built with JPS, the gradle scripting plugin
is passed in the plugin classpath. Since it is rebased on the embeddable
compiler, it hides expected plugin registrar signature, which leads to
the AbstractMethodError on attempt to load the plugin. Putting incoming
classpath at the end of the resulting one fixes the issue.
Fixes #KT-24448
This commit is contained in:
Ilya Chernikov
2018-05-15 18:39:07 +02:00
parent ea1a4f75ba
commit 4b949ef303
@@ -216,7 +216,7 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
override fun getPerformanceManager(): CommonCompilerPerformanceManager = performanceManager
private fun loadPlugins(paths: KotlinPaths?, arguments: K2JVMCompilerArguments, configuration: CompilerConfiguration): ExitCode {
val pluginClasspaths = arguments.pluginClasspaths?.toMutableList() ?: ArrayList()
var pluginClasspaths = arguments.pluginClasspaths?.asIterable() ?: emptyArray()
val pluginOptions = arguments.pluginOptions?.toMutableList() ?: ArrayList()
if (!arguments.disableDefaultScriptingPlugin) {
@@ -236,7 +236,7 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
val jars = arrayOf(KOTLIN_SCRIPTING_COMPILER_PLUGIN_JAR, KOTLIN_SCRIPTING_COMMON_JAR, KOTLIN_SCRIPTING_JVM_JAR)
.mapNotNull { File(libPath, it).takeIf { it.exists() }?.canonicalPath }
if (jars.size == 3) {
pluginClasspaths.addAll(jars)
pluginClasspaths = jars + pluginClasspaths
}
}
}