IJPL-209419 don't pack libs that are part of the product modules

GitOrigin-RevId: 7d57bcf8e7de79b98ff6287d7102292439fa8f8a
This commit is contained in:
Vladimir Krivosheev
2025-10-03 15:08:44 +00:00
committed by intellij-monorepo-bot
parent 5cd9742180
commit bf6b954065
6 changed files with 56 additions and 20 deletions
@@ -26,6 +26,7 @@ import org.jetbrains.intellij.build.impl.PlatformJarNames.TEST_FRAMEWORK_JAR
import org.jetbrains.jps.model.java.JavaSourceRootType
import org.jetbrains.jps.model.java.JpsJavaClasspathKind
import org.jetbrains.jps.model.java.JpsJavaExtensionService
import org.jetbrains.jps.model.module.JpsLibraryDependency
import org.jetbrains.jps.model.module.JpsModuleReference
import java.nio.file.Files
import java.nio.file.Path
@@ -304,14 +305,7 @@ internal suspend fun createPlatformLayout(projectLibrariesUsedByPlugins: SortedS
.sortedBy { it.moduleName },
)
val libAsProductModule: HashSet<String> = layout.includedModules.mapNotNullTo(HashSet()) {
if (it.moduleName.startsWith(LIB_MODULE_PREFIX)) {
it.moduleName.substring(LIB_MODULE_PREFIX.length).replace('.', '-')
}
else {
null
}
}
val libAsProductModule = collectExportedLibrariesFromLibraryModules(layout, context).keys
layout.libAsProductModule = libAsProductModule
// sqlite - used by DB and "import settings" (temporarily)
@@ -354,6 +348,50 @@ internal suspend fun createPlatformLayout(projectLibrariesUsedByPlugins: SortedS
return layout
}
/**
* Collects names of libraries that are exported by library modules (modules with prefix [LIB_MODULE_PREFIX]).
*
* Library modules like `intellij.libraries.grpc` export one or more project libraries
* (e.g., `grpc-core`, `grpc-stub`, `grpc-kotlin-stub`, `grpc-protobuf`).
* These exported libraries should be treated as product modules and not included separately.
*
* Note: We cannot replace all direct library references with library modules due to:
* - Dual project structures (Fleet, Toolbox) that require direct library references
* - Modules used in both production and build scripts (e.g., `intellij.platform.buildScripts.downloader`)
*
* @param layout the platform layout containing included modules
* @param context the build context
* @return map from library name to the library module that exports it
*/
fun collectExportedLibrariesFromLibraryModules(
layout: PlatformLayout,
context: BuildContext
): Map<String, String> {
val javaExtensionService = JpsJavaExtensionService.getInstance()
val result = mutableMapOf<String, String>()
layout.includedModules
.asSequence()
.filter { it.moduleName.startsWith(LIB_MODULE_PREFIX) }
.forEach { moduleItem ->
val module = context.findRequiredModule(moduleItem.moduleName)
// Get all library dependencies from the module
module.dependenciesList.dependencies
.asSequence()
.filterIsInstance<JpsLibraryDependency>()
.filter { libDep ->
// Check if this library is exported
javaExtensionService.getDependencyExtension(libDep)?.isExported == true
}
.mapNotNull { it.library?.name }
.forEach { libName ->
result[libName] = moduleItem.moduleName
}
}
return result
}
private fun getProductModuleJarName(moduleName: String, context: BuildContext, frontendModuleFilter: FrontendModuleFilter): String {
return when {
isModuleCloseSource(moduleName, context = context) -> if (frontendModuleFilter.isBackendModule(moduleName)) PRODUCT_BACKEND_JAR else PRODUCT_JAR
@@ -5,7 +5,7 @@
<module name="intellij.libraries.kotlinx.serialization.core" loading="embedded"/>
<module name="intellij.libraries.kotlinx.serialization.json" loading="embedded"/>
<module name="intellij.libraries.ktor.client"/>
<module name="intellij.libraries.ktor.client.cio"/>
<module name="intellij.libraries.ktor.client" loading="embedded"/>
<module name="intellij.libraries.ktor.client.cio" loading="embedded"/>
</content>
</idea-plugin>
+3 -4
View File
@@ -11,9 +11,8 @@ jvm_library(
"@lib//:kotlin-stdlib",
"@lib//:kotlinx-coroutines-core",
"@lib//:jetbrains-annotations",
"@lib//:ktor-client-core",
"@lib//:ktor-client-java",
],
runtime_deps = ["@lib//:kotlinx-io-core"]
"//libraries/ktor-client",
"//libraries/io",
]
)
### auto-generated section `build intellij.platform.util.http` end
@@ -26,8 +26,7 @@
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="library" name="kotlinx-coroutines-core" level="project" />
<orderEntry type="library" name="jetbrains-annotations" level="project" />
<orderEntry type="library" name="ktor-client-core" level="project" />
<orderEntry type="library" scope="RUNTIME" name="kotlinx-io-core" level="project" />
<orderEntry type="library" name="ktor-client-java" level="project" />
<orderEntry type="module" module-name="intellij.libraries.ktor.client" />
<orderEntry type="module" module-name="intellij.libraries.kotlinx.io" />
</component>
</module>
+2 -2
View File
@@ -16,7 +16,7 @@ jvm_library(
"@lib//:lz4-java",
"//platform/util-ex",
"@lib//:ktor-network-tls",
],
runtime_deps = ["@lib//:kotlinx-io-core"]
"//libraries/io",
]
)
### auto-generated section `build intellij.platform.wsl.impl` end
@@ -16,6 +16,6 @@
<orderEntry type="library" name="lz4-java" level="project" />
<orderEntry type="module" module-name="intellij.platform.util.ex" />
<orderEntry type="library" name="ktor-network-tls" level="project" />
<orderEntry type="library" scope="RUNTIME" name="kotlinx-io-core" level="project" />
<orderEntry type="module" module-name="intellij.libraries.kotlinx.io" />
</component>
</module>