diff --git a/plugins/core/jetbrains-community/resources/META-INF/aws.toolkit.core.xml b/plugins/core/jetbrains-community/resources/META-INF/aws.toolkit.core.xml index 88b37350a68..3eb636bb0de 100644 --- a/plugins/core/jetbrains-community/resources/META-INF/aws.toolkit.core.xml +++ b/plugins/core/jetbrains-community/resources/META-INF/aws.toolkit.core.xml @@ -11,7 +11,6 @@ - @@ -81,9 +80,6 @@ - - - diff --git a/plugins/core/jetbrains-community/src-242/software/aws/toolkits/jetbrains/PluginVersionChecker.kt b/plugins/core/jetbrains-community/src-242/software/aws/toolkits/jetbrains/PluginVersionChecker.kt deleted file mode 100644 index 92e527a6a61..00000000000 --- a/plugins/core/jetbrains-community/src-242/software/aws/toolkits/jetbrains/PluginVersionChecker.kt +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -package software.aws.toolkits.jetbrains - -import com.intellij.ide.ApplicationInitializedListener -import kotlinx.coroutines.CoroutineScope - -class PluginVersionChecker : ApplicationInitializedListener { - override suspend fun execute(asyncScope: CoroutineScope) { - PluginVersionCheckerImpl.execute() - } -} diff --git a/plugins/core/jetbrains-community/src-243+/software/aws/toolkits/jetbrains/PluginVersionChecker.kt b/plugins/core/jetbrains-community/src-243+/software/aws/toolkits/jetbrains/PluginVersionChecker.kt deleted file mode 100644 index 46da3856f27..00000000000 --- a/plugins/core/jetbrains-community/src-243+/software/aws/toolkits/jetbrains/PluginVersionChecker.kt +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -package software.aws.toolkits.jetbrains - -import com.intellij.ide.ApplicationInitializedListener - -class PluginVersionChecker : ApplicationInitializedListener { - override suspend fun execute() { - PluginVersionCheckerImpl.execute() - } -} diff --git a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/PluginVersionCheckerImpl.kt b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/PluginVersionCheckerImpl.kt deleted file mode 100644 index 9d21e80d40f..00000000000 --- a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/PluginVersionCheckerImpl.kt +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -package software.aws.toolkits.jetbrains - -import com.intellij.ide.plugins.IdeaPluginDescriptor -import com.intellij.ide.plugins.PluginEnabler -import com.intellij.notification.NotificationAction -import com.intellij.notification.NotificationType -import com.intellij.notification.SingletonNotificationManager -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.application.ex.ApplicationManagerEx -import com.intellij.openapi.progress.EmptyProgressIndicator -import software.aws.toolkits.core.utils.error -import software.aws.toolkits.core.utils.getLogger -import software.aws.toolkits.core.utils.info -import software.aws.toolkits.core.utils.tryOrNull -import software.aws.toolkits.core.utils.warn -import software.aws.toolkits.jetbrains.AwsToolkit.TOOLKIT_PLUGIN_ID -import software.aws.toolkits.jetbrains.core.plugin.PluginUpdateManager -import software.aws.toolkits.resources.AwsCoreBundle -import javax.swing.SwingUtilities - -object PluginVersionCheckerImpl { - 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 - } - } - ) - } - ) - } - } - - private fun shouldDisableToolkit(toolkit: PluginInfo?, updated: List): Boolean { - if (toolkit != null && updated.none { it == toolkit }) { - LOG.info { "Attempting to disable aws.toolkit due to known incompatibility" } - val descriptor = toolkit.descriptor as? IdeaPluginDescriptor ?: run { - LOG.warn { "Expected toolkit descriptor to be IdeaPluginDescriptor, but was ${toolkit.descriptor}" } - return false - } - - if (!descriptor.isEnabled) { - LOG.info { "Does not need to disable toolkit since it is already disabled" } - return false - } - - PluginEnabler.HEADLESS.disable(listOf(descriptor)) - return true - } - - return false - } - - private val LOG = getLogger() -} diff --git a/plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties b/plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties index a3cac32bd40..8a7beee4573 100644 --- a/plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties +++ b/plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties @@ -1641,9 +1641,6 @@ notification.changelog=Changelog notification.expand=Expand notification.learn_more=Learn more notification.update=Update -plugin.incompatible.fix=Disable incompatible plugins and restart IDE -plugin.incompatible.message=The plugin versions for Amazon Q, AWS Toolkit, and AWS Toolkit Core must match or conflicts may occur. -plugin.incompatible.title=AWS Plugin Incompatibility q.connection.disconnected=You don't have access to Amazon Q. Please authenticate to get started. q.connection.expired=Your Amazon Q session has timed out. Re-authenticate to continue. q.connection.invalid=You don't have access to Amazon Q. Please authenticate to get started.