[runtime repository builder] ensure that a descriptor for each JPS module name is always generated (IJPL-109)

Otherwise, dependency from 'intellij.maven.ultimate.testFramework' module to 'intellij.idea.ultimate.tests.main' breaks the generation of the module repository: the latter is considered as a test-only module, so a descriptor for its production part isn't generated, but the production part of the former has a dependency on it. It's possible to fix this by using 'test' scope for such dependencies or by adding more exceptions in 'isTestOnly' check, but it's not reliable. Given that we already have the problems with 'isTestOnly' heuristics in the past, it's better to get rid of it. This results in about 200 more descriptors created for IntelliJ Ultimate project, but this shouldn't be a problem especially when we start using more compact storage for the runtime module repository.

GitOrigin-RevId: 613c5d4a55ae853e774ded31a4ab5345646ac2e9
This commit is contained in:
Nikolay Chashnikov
2025-04-07 12:59:36 +02:00
committed by intellij-monorepo-bot
parent fa8add492f
commit f60bbd4e2c
2 changed files with 3 additions and 11 deletions

View File

@@ -143,7 +143,7 @@ internal class RuntimeModuleRepositoryBuilder
for (module in project.modules) {
//if a module doesn't have production sources, it still makes sense to generate a descriptor for it, because it may be used from code
if (!module.isTestOnly || module.hasProductionSources) {
if (!module.name.endsWith(RuntimeModuleId.TESTS_NAME_SUFFIX) || module.hasProductionSources) {
descriptors.add(createProductionPartDescriptor(module, ::getRuntimeModuleName))
}
if (GENERATE_DESCRIPTORS_FOR_TEST_MODULES && module.hasTestSources) {
@@ -152,15 +152,6 @@ internal class RuntimeModuleRepositoryBuilder
}
}
private val JpsModule.isTestOnly
get() = name.endsWith(RuntimeModuleId.TESTS_NAME_SUFFIX) ||
//todo align module names to get rid of these conditions
name.endsWith("all-tests") || name.endsWith(".test") || name.endsWith(".tests.main") || name.contains(".tests.") ||
name.endsWith("Tests") ||
name in setOf("kotlin.jvm-debugger.test.k2", "intellij.devkit.testFramework", "intellij.jupyter.testFramework",
"kotlin-ultimate.spring-tests", "intellij.goland.tools", "intellij.kotlin.testsWithAndroidPlugin", "fleet")
private val JpsModule.hasTestSources
get() = sourceRoots.any { it.rootType in JavaModuleSourceRootTypes.TESTS }

View File

@@ -68,7 +68,8 @@ class RuntimeModuleRepositoryBuilderTest : RuntimeModuleRepositoryTestCase() {
val b = addModule("b", withTests = true)
val dependency = b.dependenciesList.addModuleDependency(aTests)
JpsJavaExtensionService.getInstance().getOrCreateDependencyExtension(dependency).scope = JpsJavaDependencyScope.TEST
buildAndCheck {
buildAndCheck {
descriptor("a.test", resourceDirName = null)
testDescriptor("a.test.tests", resourceDirName = "a.test")
descriptor("b")
testDescriptor("b.tests", "b", "a.test.tests")