OPENIDE add ability bundle plugins from direct url

This commit is contained in:
Dmitry Lyubin
2026-08-11 12:44:27 +04:00
committed by Nikita Iarychenko
parent dcd3ea4f0f
commit 15eb20bd7e
2 changed files with 35 additions and 34 deletions
+1 -3
View File
@@ -21,9 +21,7 @@
<entry name="!*" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile name="jmh" enabled="true">
<module name="intellij.platform.benchmarks" />
</profile>
<profile name="jmh" enabled="true" />
</annotationProcessing>
</component>
<component name="EclipseCompilerSettings">
+34 -31
View File
@@ -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<Path> {
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)
}
}
}