[build scripts] skip unresolved optional content modules when building IDEA Community from intellij-community source code (IJPL-176806)

We have cases when a variant of IDEA Community should be built from a subset of ultimate sources, and some content modules are missing in that subset. Also, this is needed to use the same plugin.xml for the frontend and the backend variant of a plugin (IJPL-165692) if the plugin is located in intellij-community (e.g., YAML), because the frontend variant uses API which is currently not available in intellij-community.

Here a new property 'skipUnresolvedContentModules' is added to ProductModulesLayout to support such cases.

GitOrigin-RevId: 235fa3e05078ff95150dc0180634adc2c383388d
This commit is contained in:
Nikolay Chashnikov
2025-02-04 20:26:52 +00:00
committed by intellij-monorepo-bot
parent f9ca7cac87
commit 6679e91eb4
4 changed files with 29 additions and 1 deletions
@@ -65,6 +65,8 @@ open class IdeaCommunityProperties(private val communityHomeDir: Path) : BaseIde
layout.withModule("intellij.platform.duplicates.analysis")
layout.withModule("intellij.platform.structuralSearch")
}
productLayout.skipUnresolvedContentModules = true
mavenArtifacts.forIdeModules = true
mavenArtifacts.additionalModules = mavenArtifacts.additionalModules.addAll(MAVEN_ARTIFACTS_ADDITIONAL_MODULES)
@@ -6,6 +6,7 @@ package org.jetbrains.intellij.build
import it.unimi.dsi.fastutil.Hash
import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenCustomHashSet
import kotlinx.collections.immutable.*
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.intellij.build.impl.PlatformLayout
import org.jetbrains.intellij.build.impl.PluginLayout
@@ -117,6 +118,15 @@ class ProductModulesLayout {
*/
var compatiblePluginsToIgnore: PersistentList<String> = persistentListOf()
/**
* If this property is set to `true`, modules registered as optional in `content` tag in `plugin.xml` files which doesn't exist in the JPS project configuration, will be excluded
* from the distribution (by default, in such cases build scripts fail with an error).
* This can be used to build a product from a subset of a source repository. E.g., a plugin from intellij-community may refer to some additional modules located in the ultimate
* part of the project, and they should be skipped while building from intellij-community sources.
*/
@ApiStatus.Internal
var skipUnresolvedContentModules: Boolean = false
/**
* Module names which should be excluded from this product.
* Allows filtering out default platform modules (both api and implementation) as well as product modules.
@@ -238,7 +238,12 @@ class BuildContextImpl internal constructor(
@OptIn(DelicateCoroutinesApi::class)
private fun computeContentModuleFilter(): Deferred<ContentModuleFilter> {
if (productProperties.productMode == ProductMode.MONOLITH) return CompletableDeferred(IncludeAllContentModuleFilter)
if (productProperties.productMode == ProductMode.MONOLITH) {
if (productProperties.productLayout.skipUnresolvedContentModules) {
return CompletableDeferred(SkipUnresolvedOptionalContentModuleFilter(context = this))
}
return CompletableDeferred(IncludeAllContentModuleFilter)
}
return GlobalScope.async(Dispatchers.Unconfined + CoroutineName("Content Modules Filter"), start = CoroutineStart.LAZY) {
val bundledPluginModules = getBundledPluginModules()
@@ -5,6 +5,7 @@ import com.intellij.platform.runtime.product.ProductMode
import com.intellij.platform.runtime.product.impl.ProductModeMatcher
import com.intellij.platform.runtime.repository.RuntimeModuleId
import com.intellij.platform.runtime.repository.RuntimeModuleRepository
import org.jetbrains.intellij.build.BuildContext
import org.jetbrains.intellij.build.ContentModuleFilter
/**
@@ -34,4 +35,14 @@ internal class ContentModuleByProductModeFilter(
internal object IncludeAllContentModuleFilter : ContentModuleFilter {
override fun isOptionalModuleIncluded(moduleName: String, pluginMainModuleName: String?): Boolean = true
override fun toString(): String = "IncludeAllContentModuleFilter"
}
internal class SkipUnresolvedOptionalContentModuleFilter(private val context: BuildContext) : ContentModuleFilter {
override fun isOptionalModuleIncluded(moduleName: String, pluginMainModuleName: String?): Boolean {
return context.findModule(moduleName) != null;
}
override fun toString(): String = "SkipUnresolvedOptionalContentModuleFilter"
}