Do not throw on incompatible cli scripting plugin

More reliably fixes #KT-24946, #KT-24438 and alike
This commit is contained in:
Ilya Chernikov
2018-07-18 11:24:56 +02:00
parent e4b314c26c
commit a61de052c7
@@ -183,13 +183,20 @@ class KotlinCoreEnvironment private constructor(
JsSyntheticTranslateExtension.registerExtensionPoint(project) JsSyntheticTranslateExtension.registerExtensionPoint(project)
CompilerConfigurationExtension.registerExtensionPoint(project) CompilerConfigurationExtension.registerExtensionPoint(project)
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
for (registrar in configuration.getList(ComponentRegistrar.PLUGIN_COMPONENT_REGISTRARS)) { for (registrar in configuration.getList(ComponentRegistrar.PLUGIN_COMPONENT_REGISTRARS)) {
try { try {
registrar.registerProjectComponents(project, configuration) registrar.registerProjectComponents(project, configuration)
} catch (e: AbstractMethodError) { } catch (e: AbstractMethodError) {
throw IllegalStateException( val message = "The provided plugin ${registrar.javaClass.name} is not compatible with this version of compiler"
"The provided plugin ${registrar.javaClass.name} is not compatible with this version of compiler", e // Since the scripting plugin is often discovered in the compiler environment, it is often taken from the incompatible
) // location, and in many cases this is not a fatal error, therefore strong warning is generated instead of exception
if (registrar.javaClass.simpleName == "ScriptingCompilerConfigurationComponentRegistrar") {
messageCollector?.report(STRONG_WARNING, "Default scripting plugin is disabled: $message")
} else {
throw IllegalStateException(message, e)
}
} }
} }
@@ -200,7 +207,6 @@ class KotlinCoreEnvironment private constructor(
registerProjectServicesForCLI(projectEnvironment) registerProjectServicesForCLI(projectEnvironment)
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
registerProjectServices(projectEnvironment, messageCollector) registerProjectServices(projectEnvironment, messageCollector)
for (extension in CompilerConfigurationExtension.getInstances(project)) { for (extension in CompilerConfigurationExtension.getInstances(project)) {