IJPL-209476 cleanup

GitOrigin-RevId: cdf73ec973f0e6c900c13465c09ce585b58ec7e4
This commit is contained in:
Vladimir Krivosheev
2025-10-10 07:40:22 +00:00
committed by intellij-monorepo-bot
parent f2dfbb1322
commit 84f0a34d82
4 changed files with 58 additions and 29 deletions
@@ -90,14 +90,21 @@ internal class BuildTasksImpl(private val context: BuildContextImpl) : BuildTask
checkProductProperties(context)
checkPluginModules(mainPluginModules, "mainPluginModules", context)
copyDependenciesFile(context)
val pluginsToPublish = getPluginLayoutsByJpsModuleNames(mainPluginModules, context.productProperties.productLayout, toPublish = true)
val pluginsToPublish = getPluginLayoutsByJpsModuleNames(modules = mainPluginModules, productLayout = context.productProperties.productLayout, toPublish = true)
val distState = createDistributionBuilderState(pluginsToPublish, context)
context.compileModules(null)
buildProjectArtifacts(distState.platform, getEnabledPluginModules(distState.pluginsToPublish, context), context)
val searchableOptionSet = buildSearchableOptions(context.createProductRunner(mainPluginModules + dependencyModules), context)
buildNonBundledPlugins(pluginsToPublish, context.options.compressZipFiles, null, distState, searchableOptionSet, context)
buildNonBundledPlugins(
pluginsToPublish = pluginsToPublish,
compressPluginArchive = context.options.compressZipFiles,
buildPlatformLibJob = null,
state = distState,
searchableOptionSet = searchableOptionSet,
context = context,
)
}
override suspend fun buildUnpackedDistribution(targetDirectory: Path, includeBinAndRuntime: Boolean) {
@@ -310,10 +317,10 @@ private suspend fun buildOsSpecificDistributions(context: BuildContext): List<Di
async(CoroutineName("$stepId build step")) {
spanBuilder(stepId).use {
val osAndArchSpecificDistDirectory = getOsAndArchSpecificDistDirectory(os, arch, libcImpl, context)
val osAndArchSpecificDistDirectory = getOsAndArchSpecificDistDirectory(osFamily = os, arch = arch, libc = libcImpl, context = context)
builder.buildArtifacts(osAndArchSpecificDistDirectory, arch)
checkClassFiles(osAndArchSpecificDistDirectory, context, isDistAll = false)
DistributionForOsTaskResult(builder, arch, libcImpl, osAndArchSpecificDistDirectory)
checkClassFiles(root = osAndArchSpecificDistDirectory, context = context, isDistAll = false)
DistributionForOsTaskResult(builder = builder, arch = arch, libc = libcImpl, outDir = osAndArchSpecificDistDirectory)
}
}
}
@@ -360,7 +367,7 @@ private suspend fun buildSourcesArchive(contentReport: ContentReport, context: B
val openSourceModules = getIncludedModules(contentReport.bundled()).filter { moduleName ->
productProperties.includeIntoSourcesArchiveFilter.test(context.findRequiredModule(moduleName), context)
}.toList()
zipSourcesOfModules(openSourceModules, targetFile = context.paths.artifactDir.resolve(archiveName), includeLibraries = true, context)
zipSourcesOfModules(modules = openSourceModules, targetFile = context.paths.artifactDir.resolve(archiveName), includeLibraries = true, context = context)
}
internal suspend fun createDistributionState(context: BuildContext): DistributionBuilderState {
@@ -692,7 +699,7 @@ private fun checkBaseLayout(layout: BaseLayout, description: String, context: Bu
}
}
checkModules(layout.modulesWithExcludedModuleLibraries, "modulesWithExcludedModuleLibraries in $description", context)
checkModules(modules = layout.modulesWithExcludedModuleLibraries, fieldName = "modulesWithExcludedModuleLibraries in $description", context = context)
}
}
@@ -798,8 +805,8 @@ private suspend fun buildCrossPlatformZip(distResults: List<DistributionForOsTas
launch = sequenceOf(JvmArchitecture.x64, JvmArchitecture.aarch64).flatMap { arch ->
listOf(
ProductInfoLaunchData.create(
OsFamily.WINDOWS.osName,
arch.dirName,
os = OsFamily.WINDOWS.osName,
arch = arch.dirName,
launcherPath = "bin/${executableName}.bat",
javaExecutablePath = null,
vmOptionsFilePath = "bin/win/${executableName}64.exe.vmoptions",
@@ -808,8 +815,8 @@ private suspend fun buildCrossPlatformZip(distResults: List<DistributionForOsTas
mainClass = context.ideMainClassName
),
ProductInfoLaunchData.create(
OsFamily.LINUX.osName,
arch.dirName,
os = OsFamily.LINUX.osName,
arch = arch.dirName,
launcherPath = "bin/${executableName}.sh",
javaExecutablePath = null,
vmOptionsFilePath = "bin/linux/${executableName}64.vmoptions",
@@ -819,8 +826,8 @@ private suspend fun buildCrossPlatformZip(distResults: List<DistributionForOsTas
startupWmClass = getLinuxFrameClass(context)
),
ProductInfoLaunchData.create(
OsFamily.MACOS.osName,
arch.dirName,
os = OsFamily.MACOS.osName,
arch = arch.dirName,
launcherPath = "bin/${executableName}.sh",
javaExecutablePath = null,
vmOptionsFilePath = "bin/mac/${executableName}.vmoptions",
@@ -980,9 +987,9 @@ private fun crossPlatformZip(
val binEntryCustomizer = { entry: ZipArchiveEntry, path: Path, relative: String ->
entryCustomizer.invoke(entry, path, "bin/${relative}")
}
distResults.forEach {
val prefix = "bin/${it.builder.targetOs.dirName}/${it.arch.dirName}/"
out.dir(it.outDir.resolve("bin"), prefix, fileFilter = { _, relPath ->
for (result in distResults) {
val prefix = "bin/${result.builder.targetOs.dirName}/${result.arch.dirName}/"
out.dir(result.outDir.resolve("bin"), prefix, fileFilter = { _, relPath ->
relPath != "brokenPlugins.db" &&
!(relPath.startsWith(executableName) && relPath.endsWith(".exe")) &&
relPath != "${executableName}.bat" &&
@@ -995,7 +1002,7 @@ private fun crossPlatformZip(
!nonConflictingBinDirs.any(relPath::startsWith)
}, binEntryCustomizer)
out.dir(it.outDir.resolve("bin"), prefix = "bin/", fileFilter = { file, relPath ->
out.dir(result.outDir.resolve("bin"), prefix = "bin/", fileFilter = { file, relPath ->
nonConflictingBinDirs.any(relPath::startsWith)&&
filterFileIfAlreadyInZip(relPath, file, zipFileUniqueGuard)
}, binEntryCustomizer)
@@ -265,17 +265,17 @@ private fun writePluginInfo(
additional: List<Pair<Path, List<Path>>>?,
context: BuildContext,
) {
val commonClassPath = generatePluginClassPath(pluginEntries = common, moduleOutputPatcher)
val commonClassPath = generatePluginClassPath(pluginEntries = common, moduleOutputPatcher = moduleOutputPatcher)
val additionalClassPath = additional?.let { generatePluginClassPathFromPrebuiltPluginFiles(it) }
for ((supportedDist) in pluginDirs) {
val specificList = specific[supportedDist]
val specificClasspath = specificList?.let { generatePluginClassPath(pluginEntries = it, moduleOutputPatcher) }
val specificList = specific.get(supportedDist)
val specificClasspath = specificList?.let { generatePluginClassPath(pluginEntries = it, moduleOutputPatcher = moduleOutputPatcher) }
val byteOut = ByteArrayOutputStream()
val out = DataOutputStream(byteOut)
val pluginCount = common.size + (additional?.size ?: 0) + (specificList?.size ?: 0)
writePluginClassPathHeader(out, isJarOnly = true, pluginCount, moduleOutputPatcher, context)
writePluginClassPathHeader(out = out, isJarOnly = true, pluginCount = pluginCount, moduleOutputPatcher = moduleOutputPatcher, context = context)
out.write(commonClassPath)
additionalClassPath?.let { out.write(it) }
specificClasspath?.let { out.write(it) }
@@ -897,6 +897,7 @@ private suspend fun checkOutputOfPluginModules(
module == "intellij.java.guiForms.rt" ||
!containsFileInOutput(module, "com/intellij/uiDesigner/core/GridLayoutManager.class", moduleExcludes.get(module) ?: emptyList(), context)
) {
@Suppress("GrazieInspection")
"Runtime classes of GUI designer must not be packaged to '$module' module in '$mainPluginModule' plugin, " +
"because they are included into a platform JAR. Make sure that 'Automatically copy form runtime classes " +
"to the output directory' is disabled in Settings | Editor | GUI Designer."
@@ -1269,7 +1270,7 @@ private suspend fun checkModuleExcludes(moduleExcludes: Map<String, List<String>
for (module in moduleExcludes.keys) {
check(context.getModuleOutputRoots(context.findRequiredModule(module)).all(Files::exists)) {
"There are excludes defined for module '${module}', but the module wasn't compiled;" +
" most probably it means that '${module}' isn't included into the product distribution," +
" most probably it means that '${module}' isn't included in the product distribution," +
" so it doesn't make sense to define excludes for it."
}
}
@@ -185,20 +185,36 @@ class MacDistributionBuilder(
val builder = this@MacDistributionBuilder
val productJson = generateProductJson(context, arch, withRuntime = true)
val productJsonWithoutRuntime = generateProductJson(context, arch, withRuntime = false)
val productJsonWithoutRuntime = generateProductJson(context = context, arch = arch, withRuntime = false)
withContext(Dispatchers.IO) {
macZipProductInfoJson.writeText(productJson)
macZipWithoutRuntimeProductInfoJson.writeText(productJsonWithoutRuntime)
}
buildMacZip(
builder, macZip, zipRoot, arch, productJson, directories, extraFiles, includeRuntime = true, compressionLevel
macDistributionBuilder = builder,
targetFile = macZip,
zipRoot = zipRoot,
arch = arch,
productJson = productJson,
directories = directories,
extraFiles = extraFiles,
includeRuntime = true,
compressionLevel = compressionLevel,
)
if (customizer.buildArtifactWithoutRuntime) {
val directoriesSansRuntime = directories.filterNot { it == runtimeDir }
buildMacZip(
builder, macZipWithoutRuntime, zipRoot, arch, productJsonWithoutRuntime, directoriesSansRuntime, extraFiles, includeRuntime = false, compressionLevel
macDistributionBuilder = builder,
targetFile = macZipWithoutRuntime,
zipRoot = zipRoot,
arch = arch,
productJson = productJsonWithoutRuntime,
directories = directoriesSansRuntime,
extraFiles = extraFiles,
includeRuntime = false,
compressionLevel = compressionLevel,
)
}
@@ -212,7 +228,13 @@ class MacDistributionBuilder(
}
}
else {
buildForArch(arch, macZip, macZipProductInfoJson, macZipWithoutRuntime, macZipWithoutRuntimeProductInfoJson)
buildForArch(
arch = arch,
macZip = macZip,
macZipProductInfoJson = macZipProductInfoJson,
macZipWithoutRuntime = macZipWithoutRuntime,
macZipWithoutRuntimeProductInfoJson = macZipWithoutRuntimeProductInfoJson,
)
}
}
}
@@ -231,7 +253,7 @@ class MacDistributionBuilder(
signMacBinaries(binariesToSign, context)
for (dir in listOf(osAndArchSpecificDistPath, runtimeDist)) {
launch(CoroutineName("recursively signing macOS binaries in $dir")) {
recursivelySignMacBinaries(coroutineScope = this, dir, context, matchers)
recursivelySignMacBinaries(coroutineScope = this, root = dir, context = context, executableFileMatchers = matchers)
}
}
}
@@ -586,8 +586,7 @@ private val COMMUNITY_IMPL_EXTENSIONS = setOf(
fun createXIncludePathResolver(includedPlatformModulesPartialList: List<String>, context: BuildContext): XIncludePathResolver {
return object : XIncludePathResolver {
override fun resolvePath(relativePath: String, base: Path?, isOptional: Boolean, isDynamic: Boolean): Path? {
if ((isOptional || isDynamic || excludedPaths.contains(relativePath))
&& !COMMUNITY_IMPL_EXTENSIONS.contains(relativePath)) {
if ((isOptional || isDynamic || excludedPaths.contains(relativePath)) && !COMMUNITY_IMPL_EXTENSIONS.contains(relativePath)) {
// It isn't safe to resolve includes at build time if they're optional.
// This could lead to issues when running another product using this distribution.
// E.g., if the corresponding module is somehow being excluded on runtime.