ASPR-3010 Recommended plugin installation on IDEA startup (fix required plugins downloads)

This commit is contained in:
Nikita Iarychenko
2026-03-03 18:07:45 +04:00
parent 75cffabd34
commit 21d961b26e
2 changed files with 27 additions and 4 deletions

View File

@@ -170,7 +170,7 @@ class OpenIdeStartupWizardService(private val coroutineScope: CoroutineScope) :
icon = AllIcons.Language.GO,
plugins = listOf(
WizardPluginImpl(
id = "org.jetbrains.plugins.go",
id = "com.haulmont.go",
icon = AllIcons.Plugins.PluginLogo,
name = "Go [beta]",
description = ImportSettingsBundle.message("plugin.description.go"),

View File

@@ -67,12 +67,20 @@ object PluginInstallationUtil {
}
var shouldRestart = false
val progressPerPlugin = 0.9 / pluginsToInstall.size.coerceAtLeast(1)
val installedDuringSession = mutableSetOf<PluginId>()
val queue = ArrayDeque(pluginsToInstall)
var currentProgress = 0.1
for (plugin in pluginsToInstall) {
while (queue.isNotEmpty()) {
if (progressIndicator.isCanceled) break
val plugin = queue.removeFirst()
if (plugin.pluginId in installedDuringSession || PluginManagerCore.isPluginInstalled(plugin.pluginId)) {
continue
}
val progressPerPlugin = 0.9 / (queue.size + 1).coerceAtLeast(1)
progressIndicator.text = ImportSettingsBundle.message("plugin-installation.progress.downloading", plugin.name)
// Load and set plugin icon
@@ -94,13 +102,28 @@ object PluginInstallationUtil {
}
withContext(Dispatchers.IO) {
downloader.prepareToInstall(null)
val prepareToInstall = downloader.prepareToInstall(null)
if (prepareToInstall) {
val depIds = downloader.descriptor
.dependencies
.filter { !it.isOptional }
.map { it.pluginId }
.filter { it !in installedDuringSession && !PluginManagerCore.isPluginInstalled(it) }
if (depIds.isNotEmpty()) {
val depDescriptors = MarketplaceRequests.loadLastCompatiblePluginDescriptors(depIds.toSet(), null, true)
queue.addAll(depDescriptors)
}
}
}
val appliedWithoutRestart = withContext(Dispatchers.EDT + ModalityState.any().asContextElement()) {
downloader.installDynamically(null)
}
installedDuringSession.add(plugin.pluginId)
if (!appliedWithoutRestart) {
shouldRestart = true
}