From 15eb20bd7e5acd98f3ebaf5bb24aa0f7ff5f2320 Mon Sep 17 00:00:00 2001 From: Dmitry Lyubin Date: Wed, 17 Jun 2026 01:46:07 +0400 Subject: [PATCH] OPENIDE add ability bundle plugins from direct url --- .idea/compiler.xml | 4 +- .../src/ru/openide/OpenIdePluginBundler.kt | 65 ++++++++++--------- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index e634a14ef8af..6fd087103e74 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -21,9 +21,7 @@ - - - + diff --git a/openide/src/ru/openide/OpenIdePluginBundler.kt b/openide/src/ru/openide/OpenIdePluginBundler.kt index b4a7fee3e1f8..ea73def919d1 100644 --- a/openide/src/ru/openide/OpenIdePluginBundler.kt +++ b/openide/src/ru/openide/OpenIdePluginBundler.kt @@ -20,6 +20,8 @@ import org.jetbrains.intellij.build.BuildContext import org.jetbrains.intellij.build.BuildPaths.Companion.COMMUNITY_ROOT import org.jetbrains.intellij.build.dependencies.BuildDependenciesDownloader import org.jetbrains.intellij.build.dependencies.BuildDependenciesExtractOptions +import ru.openide.OpenIdePluginBundler.PluginSource.DirectUrl +import ru.openide.OpenIdePluginBundler.PluginSource.Marketplace import java.net.URI import java.nio.file.Path @@ -27,50 +29,51 @@ object OpenIdePluginBundler { private const val DOWNLOADABLE_PLUGINS_DIR = "build/download/plugins" private const val PLUGINS_DOWNLOAD_URL = "https://plugins.openide.ru/pluginManager" - private const val PLUGIN_DOWNLOAD_BY_VERSION_URL = "https://plugins.openide.ru/plugin/download" private val plugins = listOf( - PluginInfo("com.haulmont.intellij.rupack", "ru_pack"), - PluginInfo("com.haulmont.amplicode", "amplicode"), - PluginInfo("ru.openide.pro.updater", "updater") + Marketplace("com.haulmont.intellij.rupack", "ru_pack"), + Marketplace("ru.openide.pro.updater", "updater"), + Marketplace("com.haulmont.amplicode", "amplicode"), + DirectUrl("https://download.openide.ru/plugins/OpenIDE-DB-Client-0.0.17.zip", "dbclient") ) fun getBundlePluginPaths(context: BuildContext): List { if (System.getProperty("without.bundle.plugins") != null) return emptyList() - val communityHomeDir = context.paths.communityHomeDir - return plugins.map { - Path.of("${communityHomeDir}/$DOWNLOADABLE_PLUGINS_DIR/${it.folderName}") - } + return plugins.map { it.targetDir(context) } } fun bundlePlugins(context: BuildContext) { runBlocking(Dispatchers.Default) { - plugins.forEach { bundlePluginFromMarketplace(context, it) } + plugins.forEach { bundlePlugin(context, it) } } } - private suspend fun bundlePluginFromMarketplace(context: BuildContext, pluginInfo: PluginInfo) { - val url = if (pluginInfo.version != null) { - Urls.newFromEncoded(PLUGIN_DOWNLOAD_BY_VERSION_URL) - .addParameters(hashMapOf( - "pluginId" to pluginInfo.pluginId, - "version" to pluginInfo.version - )) - } - else { - Urls.newFromEncoded(PLUGINS_DOWNLOAD_URL) - .addParameters(hashMapOf( - "id" to pluginInfo.pluginId, - "build" to context.fullBuildNumber - )) - } - - val uri = url.toExternalForm().let(URI::create) - - val archivePath = BuildDependenciesDownloader.downloadFileToCacheLocation(COMMUNITY_ROOT, uri) - val targetDir = context.paths.communityHomeDir.resolve("$DOWNLOADABLE_PLUGINS_DIR/${pluginInfo.folderName}") - BuildDependenciesDownloader.extractFile(archivePath, targetDir, COMMUNITY_ROOT, BuildDependenciesExtractOptions.STRIP_ROOT) + private suspend fun bundlePlugin(context: BuildContext, source: PluginSource) { + val archivePath = BuildDependenciesDownloader.downloadFileToCacheLocation(COMMUNITY_ROOT, source.resolveUri(context)) + BuildDependenciesDownloader.extractFile(archivePath, source.targetDir(context), COMMUNITY_ROOT, BuildDependenciesExtractOptions.STRIP_ROOT) } - private class PluginInfo(val pluginId: String, val folderName: String, val version: String? = null) + private sealed class PluginSource(val folderName: String) { + abstract fun resolveUri(context: BuildContext): URI + + fun targetDir(context: BuildContext): Path = + context.paths.communityHomeDir.resolve("$DOWNLOADABLE_PLUGINS_DIR/$folderName") + + /** Plugin resolved through the OpenIDE marketplace by its plugin id. */ + class Marketplace(private val pluginId: String, folderName: String) : PluginSource(folderName) { + override fun resolveUri(context: BuildContext): URI = + Urls.newFromEncoded(PLUGINS_DOWNLOAD_URL) + .addParameters(mapOf("id" to pluginId, "build" to context.fullBuildNumber)) + .toExternalForm() + .let(URI::create) + } + + /** Plugin downloaded directly from a fixed archive URL. */ + class DirectUrl(private val url: String, folderName: String) : PluginSource(folderName) { + override fun resolveUri(context: BuildContext): URI = + Urls.newFromEncoded(url) + .toExternalForm() + .let(URI::create) + } + } } \ No newline at end of file