From e25cabae465ef9b9b3db8e99a80a938ca7fe29b4 Mon Sep 17 00:00:00 2001 From: Nikolay Chashnikov Date: Thu, 1 May 2025 12:51:01 +0200 Subject: [PATCH] [build script tests] check that classpaths for plugins in the frontend don't include JARs from the core plugin for embedded frontend as well (IJPL-185969) 'checkProductModules' is now called for embedded frontend distribution, not only for standalone frontend distributions. The error message is improved to describe possible solutions. 'intellij.performanceTesting.async' plugin in IDEA Community is excluded from the check until IJPL-186414 is fixed. GitOrigin-RevId: 26b156139688bf239ab87c14629054aa7b212e68 --- .../RuntimeModuleRepositoryChecker.kt | 21 +++++++++++++++---- .../testFramework/buildScriptTestUtils.kt | 1 + 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/platform/build-scripts/testFramework/src/com/intellij/platform/buildScripts/testFramework/RuntimeModuleRepositoryChecker.kt b/platform/build-scripts/testFramework/src/com/intellij/platform/buildScripts/testFramework/RuntimeModuleRepositoryChecker.kt index c2fbec485e9d..863bd05380c3 100644 --- a/platform/build-scripts/testFramework/src/com/intellij/platform/buildScripts/testFramework/RuntimeModuleRepositoryChecker.kt +++ b/platform/build-scripts/testFramework/src/com/intellij/platform/buildScripts/testFramework/RuntimeModuleRepositoryChecker.kt @@ -103,6 +103,12 @@ internal class RuntimeModuleRepositoryChecker private constructor( productModules.bundledPluginModuleGroups.forEach { group -> val allPluginModules = group.includedModules.map { it.moduleDescriptor } + serviceModuleMapping.getAdditionalModules(group) + if (group.mainModule.moduleId == RuntimeModuleId.module("intellij.performanceTesting.async") && context.applicationInfo.productCode == "IC") { + //'intellij.performanceTesting.async' bundled with IDEA Community includes modules which are included in the core plugin for IDEA Ultimate, + //so it won't be loaded in IDEA Community, see IJPL-186414 + return@forEach + } + for (pluginModule in allPluginModules) { if (pluginModule.moduleId == RuntimeModuleId.projectLibrary("commons-lang3")) { //ignore this error until IJPL-671 is fixed @@ -114,12 +120,19 @@ internal class RuntimeModuleRepositoryChecker private constructor( if (mainModules != null) { val mainModuleListString = if (mainModules.size < 3) mainModules.joinToString { it.stringId } - else "${mainModules.first().stringId} and ${mainModules.size - 1} more modules" + else "${mainModules.first().stringId} and ${mainModules.size - 1} more modules" + val moduleId = pluginModule.moduleId.stringId + val pluginModuleId = group.mainModule.moduleId.stringId softly.collectAssertionErrorIfNotRegisteredYet( AssertionError(""" - |Module '${pluginModule.moduleId.stringId}' from plugin '${group.mainModule.moduleId}' has resource root $resourcePath, - |which is also added as a resource root of modules from the platform part ($mainModuleListString). - """.trimMargin())) + |Module '$moduleId' from plugin '$pluginModuleId' has resource root ${commonDistPath.relativize(resourcePath)}, + |which is also added as a resource root of modules from the core (platform) plugin ($mainModuleListString). + |This may lead to classes from the core plugin to be loaded by two classloaders leading to ClassCastException at runtime. + |If '$moduleId' belongs to '$pluginModuleId' plugin, make sure that it's included in the plugin layout (if it's registered as a content module, it should be enough to remove + |explicit references to it from the build scripts, and it'll be packed in the plugin automatically). + |If '$moduleId' is a part of the core plugin, don't register it as a content module in '$pluginModuleId', and register it in `main-root-modules` tag in + |`product-modules.xml` instead. + |""".trimMargin())) } } } diff --git a/platform/build-scripts/testFramework/src/com/intellij/platform/buildScripts/testFramework/buildScriptTestUtils.kt b/platform/build-scripts/testFramework/src/com/intellij/platform/buildScripts/testFramework/buildScriptTestUtils.kt index 9c67142ce94d..c8d4f7ce3b01 100644 --- a/platform/build-scripts/testFramework/src/com/intellij/platform/buildScripts/testFramework/buildScriptTestUtils.kt +++ b/platform/build-scripts/testFramework/src/com/intellij/platform/buildScripts/testFramework/buildScriptTestUtils.kt @@ -200,6 +200,7 @@ private suspend fun doRunTestBuild(context: BuildContext, traceSpanName: String, if (checkIntegrityOfEmbeddedFrontend) { val frontendRootModule = context.productProperties.embeddedFrontendRootModule if (frontendRootModule != null && context.generateRuntimeModuleRepository) { + RuntimeModuleRepositoryChecker.checkProductModules(productModulesModule = frontendRootModule, context = context, softly = softly) RuntimeModuleRepositoryChecker.checkIntegrityOfEmbeddedFrontend(frontendRootModule, context, softly) checkKeymapPluginsAreBundledWithFrontend(frontendRootModule, context, softly) }