From facf998a065b5e2dfc8aaf2308fa670f3dd41c8c Mon Sep 17 00:00:00 2001 From: Nikolay Chashnikov Date: Tue, 27 May 2025 17:37:50 +0200 Subject: [PATCH] [plugin model] provide a way to automatically add newly extracted content modules to dependencies of existing plugins (IJPL-188866) 'contentModulesExtractedInCorePluginWhichCanBeUsedFromExternalPlugins' property is introduced to allow extracting new content modules from the core platform without breaking compatibility with external plugins. Actual values and a test for the new behavior will be added in next commits. GitOrigin-RevId: 22bbc3874dfad79f69196193dff03eff0a428ac5 --- .../ide/plugins/ModulesWithDependencies.kt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/platform/core-impl/src/com/intellij/ide/plugins/ModulesWithDependencies.kt b/platform/core-impl/src/com/intellij/ide/plugins/ModulesWithDependencies.kt index eea6f4edf084..1adc8c4d2098 100644 --- a/platform/core-impl/src/com/intellij/ide/plugins/ModulesWithDependencies.kt +++ b/platform/core-impl/src/com/intellij/ide/plugins/ModulesWithDependencies.kt @@ -170,12 +170,22 @@ private val knownNotFullyMigratedPluginIds: Set = hashSetOf( "com.jetbrains.pycharm.ds.customization", ) +/** + * Specifies the list of content modules which was recently extracted from the main module of the core plugin and may have external usages. + * Since such modules were loaded by the core classloader before, it wasn't necessary to specify any dependencies to use classes from them. + * To avoid breaking compatibility, dependencies on these modules are automatically added to plugins which define dependency on the platform using + * `com.intellij.modules.platformcom.intellij.modules.lang( +) + private fun collectDirectDependenciesInOldFormat(rootDescriptor: IdeaPluginDescriptorImpl, idMap: Map, dependenciesCollector: MutableSet) { for (dependency in rootDescriptor.dependencies) { // check for missing optional dependency - val dep = idMap.get(dependency.pluginId.idString) ?: continue + val dependencyPluginId = dependency.pluginId.idString + val dep = idMap.get(dependencyPluginId) ?: continue if (dep.pluginId != PluginManagerCore.CORE_ID || dep is ContentModuleDescriptor) { // ultimate plugin it is combined plugin, where some included XML can define dependency on ultimate explicitly and for now not clear, // can be such requirements removed or not @@ -191,6 +201,13 @@ private fun collectDirectDependenciesInOldFormat(rootDescriptor: IdeaPluginDescr dependenciesCollector.add(dep) } } + if (dependencyPluginId == "com.intellij.modules.platform" || dependencyPluginId == "com.intellij.modules.lang") { + for (contentModuleName in contentModulesExtractedInCorePluginWhichCanBeUsedFromExternalPlugins) { + idMap.get(contentModuleName)?.let { + dependenciesCollector.add(it) + } + } + } if (knownNotFullyMigratedPluginIds.contains(rootDescriptor.pluginId.idString)) { dependenciesCollector.addAll(idMap.get(PluginManagerCore.CORE_ID.idString)!!.contentModules)