mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[build scripts] automatically include required content modules in the main plugin JAR (IJPL-230)
Since content modules with 'loading=required' use the main plugin classloader (see IJPL-148565), we can safely include them in the main plugin jar even if they don't specify 'package' attribute. This way we can skip specifying custom PluginLayout for such plugins. GitOrigin-RevId: 66163fa21f01f1de7d3b76269e5bd18bc3eb895c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
795434cfb9
commit
d85dc7ea61
+11
-4
@@ -3,6 +3,7 @@
|
||||
|
||||
package org.jetbrains.intellij.build
|
||||
|
||||
import com.intellij.platform.runtime.product.RuntimeModuleLoadingRule
|
||||
import com.intellij.util.xml.dom.XmlElement
|
||||
import com.intellij.util.xml.dom.readXmlAsModel
|
||||
import org.jetbrains.intellij.build.impl.ModuleItem
|
||||
@@ -76,7 +77,7 @@ internal class JarPackagerDependencyHelper(private val context: BuildContext) {
|
||||
return element.content!!
|
||||
}
|
||||
|
||||
suspend fun readPluginContentFromDescriptor(pluginModule: JpsModule, moduleOutputPatcher: ModuleOutputPatcher): Sequence<String> {
|
||||
suspend fun readPluginContentFromDescriptor(pluginModule: JpsModule, moduleOutputPatcher: ModuleOutputPatcher): Sequence<Pair<String, RuntimeModuleLoadingRule>> {
|
||||
return readPluginContentFromDescriptor(getResolvedPluginDescriptor(pluginModule, moduleOutputPatcher))
|
||||
}
|
||||
|
||||
@@ -88,15 +89,21 @@ internal class JarPackagerDependencyHelper(private val context: BuildContext) {
|
||||
// The x-include is not resolved. If the plugin.xml includes any files, the content from these included files will not be considered.
|
||||
fun readPluginIncompleteContentFromDescriptor(pluginModule: JpsModule): Sequence<String> {
|
||||
val pluginXml = context.findFileInModuleSources(pluginModule, "META-INF/plugin.xml") ?: return emptySequence()
|
||||
return readPluginContentFromDescriptor(readXmlAsModel(pluginXml))
|
||||
return readPluginContentFromDescriptor(readXmlAsModel(pluginXml)).map { it.first }
|
||||
}
|
||||
|
||||
private fun readPluginContentFromDescriptor(pluginDescriptor: XmlElement): Sequence<String> {
|
||||
private fun readPluginContentFromDescriptor(pluginDescriptor: XmlElement): Sequence<Pair<String, RuntimeModuleLoadingRule>> {
|
||||
return sequence {
|
||||
for (content in pluginDescriptor.children("content")) {
|
||||
for (module in content.children("module")) {
|
||||
val moduleName = module.attributes.get("name")?.takeIf { !it.contains('/') } ?: continue
|
||||
yield(moduleName)
|
||||
val loadingRuleString = module.attributes.get("loading")
|
||||
val loadingRule = when (loadingRuleString) {
|
||||
"required" -> RuntimeModuleLoadingRule.REQUIRED
|
||||
"on-demand" -> RuntimeModuleLoadingRule.ON_DEMAND
|
||||
else -> RuntimeModuleLoadingRule.OPTIONAL
|
||||
}
|
||||
yield(moduleName to loadingRule)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.intellij.build
|
||||
|
||||
import com.intellij.platform.runtime.product.RuntimeModuleLoadingRule
|
||||
import com.intellij.util.xml.dom.readXmlAsModel
|
||||
import org.jetbrains.intellij.build.impl.*
|
||||
|
||||
@@ -60,7 +61,7 @@ internal suspend fun computeModuleSourcesByContent(
|
||||
jarPackager: JarPackager,
|
||||
searchableOptionSet: SearchableOptionSetDescriptor?
|
||||
) {
|
||||
for (moduleName in helper.readPluginContentFromDescriptor(context.findRequiredModule(layout.mainModule), jarPackager.moduleOutputPatcher)) {
|
||||
for ((moduleName, loadingRule) in helper.readPluginContentFromDescriptor(context.findRequiredModule(layout.mainModule), jarPackager.moduleOutputPatcher)) {
|
||||
// CWM plugin is overcomplicated without any valid reason - it must be refactored
|
||||
if (moduleName == "intellij.driver.backend.split" || !addedModules.add(moduleName)) {
|
||||
continue
|
||||
@@ -70,7 +71,7 @@ internal suspend fun computeModuleSourcesByContent(
|
||||
val forTests = (context as? BuildContextImpl)?.jarPackagerDependencyHelper?.isTestPluginModule(moduleName) ?: false
|
||||
val descriptor = readXmlAsModel(context.findFileInModuleSources(module, "$moduleName.xml", forTests)
|
||||
?: error("$moduleName.xml not found in module $moduleName sources"))
|
||||
val useSeparateJar = descriptor.getAttributeValue("package") == null || helper.isPluginModulePackedIntoSeparateJar(module, layout)
|
||||
val useSeparateJar = (descriptor.getAttributeValue("package") == null || helper.isPluginModulePackedIntoSeparateJar(module, layout)) && loadingRule != RuntimeModuleLoadingRule.REQUIRED
|
||||
jarPackager.computeSourcesForModule(
|
||||
item = ModuleItem(
|
||||
moduleName = moduleName,
|
||||
|
||||
Reference in New Issue
Block a user