From f56180cada0f46d5809e14b6d2c6a9caadbcead1 Mon Sep 17 00:00:00 2001 From: Dmitrii Gridin Date: Mon, 29 Sep 2025 17:25:56 +0200 Subject: [PATCH] [kotlin] project-model-updater: drop modules.xml clone It is the responsibility of `CommunityProjectConsistencyTest` to unsure that monorepo and community modules are in sync ^KTIJ-35777 GitOrigin-RevId: f62d41fbb08d5b08ab8a93052810d5b810e3a88b --- .../org/jetbrains/tools/model/updater/Main.kt | 61 ++----------------- 1 file changed, 4 insertions(+), 57 deletions(-) diff --git a/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/Main.kt b/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/Main.kt index ec52961a4906..857e25f63782 100644 --- a/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/Main.kt +++ b/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/Main.kt @@ -1,8 +1,10 @@ // Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.tools.model.updater -import org.jdom.Document -import org.jetbrains.tools.model.updater.impl.* +import org.jetbrains.tools.model.updater.impl.JpsLibrary +import org.jetbrains.tools.model.updater.impl.JpsResolverSettings +import org.jetbrains.tools.model.updater.impl.Preferences +import org.jetbrains.tools.model.updater.impl.readJpsResolverSettings import java.nio.file.Path import java.util.* import kotlin.io.path.* @@ -90,7 +92,6 @@ fun main(args: Array) { if (monorepoRoot != null) { processRoot(monorepoRoot, isCommunity = false) - cloneModuleStructure(monorepoRoot, communityRoot) } processRoot(communityRoot, isCommunity = true) @@ -114,31 +115,6 @@ private fun regenerateProjectLibraries(dotIdea: Path, libraries: List module.isCommunity && module.dependencies.all { dep -> monorepoModules[dep]?.isCommunity ?: false } } - .mapValues { (_, module) -> module.copy(path = module.path.removePrefix("community/")) } - - val newCommunityModulesXmlContent = xml("project", "version" to "4") { - xml("component", "name" to "ProjectModuleManager") { - xml("modules") { - for (module in communityModules.values) { - val modulePath = $$"$PROJECT_DIR$/$${module.path}" - xml("module", "fileurl" to "file://$modulePath", "filepath" to modulePath) - } - } - } - } - - communityModulesFile.writeText(newCommunityModulesXmlContent.render(addXmlDeclaration = true)) -} - private fun updateCoopRunConfiguration(monorepoRoot: Path?, communityRoot: Path) { val runConfigurationFilePath = ".idea/runConfigurations/Kotlin_Coop__Publish_compiler_for_ide_JARs.xml" val communityRunConfigurationFile = communityRoot.resolve(runConfigurationFilePath) @@ -200,32 +176,3 @@ private fun updateFile(sourceFile: Path, regexp: String, replacement: String) { sourceFile.writeText(updatedFileContent) } - -private data class JpsModule(val name: String, val path: String, val dependencies: List) { - val isCommunity: Boolean - get() = path.startsWith("community/") -} - -private fun readModules(root: Path, document: Document): Map { - val projectModuleManagerComponent = document.rootElement.getChildren("component") - .first { it.getAttributeValue("name") == "ProjectModuleManager" } - - val result = LinkedHashMap() - - for (moduleEntry in projectModuleManagerComponent.getChild("modules").getChildren("module")) { - val modulePath = moduleEntry.getAttributeValue("filepath").removePrefix($$"$PROJECT_DIR$/") - val moduleName = modulePath.substringAfterLast("/").removeSuffix(".iml") - - val moduleXml = root.resolve(modulePath).readXml() - val moduleRootManagerComponent = moduleXml.rootElement.getChildren("component") - .first { it.getAttributeValue("name") == "NewModuleRootManager" } - - val dependencies = moduleRootManagerComponent.getChildren("orderEntry") - .filter { it.getAttributeValue("type") == "module" } - .mapNotNull { it.getAttributeValue("module-name") } - - result[moduleName] = JpsModule(moduleName, modulePath, dependencies) - } - - return result -}