in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/PluginVersionCheckerImpl.kt [25:92]
fun execute() {
if (ApplicationManager.getApplication().isHeadlessEnvironment) {
LOG.info { "Skipping due to headless environment" }
return
}
val core = AwsToolkit.PLUGINS_INFO.get(AwsPlugin.CORE) ?: return
val mismatch = AwsToolkit.PLUGINS_INFO.values.filter { it.descriptor?.isEnabled == true && it.version != core.version }
if (mismatch.isEmpty()) {
return
}
LOG.info { "Mismatch between core version: ${core.version} and plugins: $mismatch" }
val updated = mismatch.filter {
val descriptor = it.descriptor as? IdeaPluginDescriptor ?: return@filter false
return@filter try {
PluginUpdateManager.updatePlugin(descriptor, EmptyProgressIndicator())
} catch (e: Exception) {
LOG.error(e) { "Failed to update $descriptor" }
false
}
}
// defensively disable the old toolkit if we couldn't update it because we might deadlock during project open
val toolkit = mismatch.firstOrNull { it.id == TOOLKIT_PLUGIN_ID && it.version?.startsWith("2.") == true }
if (shouldDisableToolkit(toolkit, updated) || updated.isNotEmpty()) {
LOG.info { "Restarting due to forced update of plugins" }
// IDE invokeLater is not initialized yet
SwingUtilities.invokeAndWait {
ApplicationManagerEx.getApplicationEx().restart(true)
}
return
}
val notificationGroup = SingletonNotificationManager("aws.plugin.version.mismatch", NotificationType.WARNING)
notificationGroup.notify(
AwsCoreBundle.message("plugin.incompatible.title"),
AwsCoreBundle.message("plugin.incompatible.message"),
null
) {
it.isImportant = true
it.addAction(
NotificationAction.createSimpleExpiring(AwsCoreBundle.message("plugin.incompatible.fix")) {
// try update core and disable everything else
val coreDescriptor = core.descriptor as? IdeaPluginDescriptor
tryOrNull {
coreDescriptor?.let { descriptor -> PluginUpdateManager.updatePlugin(descriptor, EmptyProgressIndicator()) }
}
PluginEnabler.HEADLESS.disable(
AwsToolkit.PLUGINS_INFO.values.mapNotNull {
val descriptor = it.descriptor as? IdeaPluginDescriptor
if (descriptor != null && descriptor != core.descriptor) {
descriptor
} else {
null
}
}
)
}
)
}
}