diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/JarPackager.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/JarPackager.kt index fa803776026a..b237c7ecdd65 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/JarPackager.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/JarPackager.kt @@ -346,7 +346,7 @@ class JarPackager private constructor( val outFile = outDir.resolve(item.relativeOutputFile) val asset = if (packToDir) { assets.computeIfAbsent(moduleOutDir) { file -> - AssetDescriptor(isDir = true, file = file, relativePath = "", pathInClassLog = "") + AssetDescriptor(isDir = true, file = file, relativePath = "", pathInClassLog = "", nativeFiles = null) } } else { @@ -753,7 +753,7 @@ private data class AssetDescriptor( @JvmField val relativePath: String, @JvmField var effectiveFile: Path = file, @JvmField val pathInClassLog: String, - @JvmField val nativeFiles: List? = null + @JvmField val nativeFiles: List?, ) { @JvmField val sources: MutableList = mutableListOf() @@ -851,21 +851,12 @@ private suspend fun buildJars( dryRun: Boolean, layout: BaseLayout? ): Map> { - val uniqueFiles = HashMap>() - for (descriptor in assets) { - val existing = uniqueFiles.putIfAbsent(descriptor.file, descriptor.sources) - check(existing == null) { - "File ${descriptor.file} is already associated." + - "\nPrevious:\n ${existing!!.joinToString(separator = "\n ")}" + - "\nCurrent:\n ${descriptor.sources.joinToString(separator = "\n ")}" - } - } + checkAssetUniqueness(assets) if (dryRun) { return emptyMap() } - //val optimizeLibraryContext = OptimizeLibraryContext(tempDir = context.paths.tempDir, javaHome = context.getStableJdkHome()) val list = withContext(Dispatchers.IO) { assets.map { asset -> async { @@ -929,6 +920,18 @@ private suspend fun buildJars( return result } +private fun checkAssetUniqueness(assets: Collection) { + val uniqueFiles = HashMap>(assets.size) + for (asset in assets) { + val existing = uniqueFiles.putIfAbsent(asset.file, asset.sources) + check(existing == null) { + "File ${asset.file} is already associated." + + "\nPrevious:\n ${existing!!.joinToString(separator = "\n ")}" + + "\nCurrent:\n ${asset.sources.joinToString(separator = "\n ")}" + } + } +} + private class NativeFileHandlerImpl(private val context: BuildContext, private val descriptor: AssetDescriptor) : NativeFileHandler { override val sourceToNativeFiles = HashMap>() diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/mergeJars.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/mergeJars.kt index 44779bdb38a3..9baadc753325 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/mergeJars.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/mergeJars.kt @@ -150,15 +150,19 @@ suspend fun buildJar(targetFile: Path, sources: List, compress: Boolean buildJar(targetFile = targetFile, sources = sources, compress = compress, nativeFileHandler = null) } -internal suspend fun buildJar(targetFile: Path, - sources: List, - compress: Boolean = false, - notify: Boolean = true, - nativeFileHandler: NativeFileHandler? = null) { +internal suspend fun buildJar( + targetFile: Path, + sources: List, + compress: Boolean = false, + notify: Boolean = true, + nativeFileHandler: NativeFileHandler? = null, +) { val packageIndexBuilder = if (compress) null else PackageIndexBuilder() writeNewFile(targetFile) { outChannel -> - ZipFileWriter(channel = outChannel, - deflater = if (compress) Deflater(Deflater.DEFAULT_COMPRESSION, true) else null).use { zipCreator -> + ZipFileWriter( + channel = outChannel, + deflater = if (compress) Deflater(Deflater.DEFAULT_COMPRESSION, true) else null, + ).use { zipCreator -> val uniqueNames = HashMap() for (source in sources) { @@ -181,8 +185,10 @@ internal suspend fun buildJar(targetFile: Path, is InMemoryContentSource -> { if (uniqueNames.putIfAbsent(source.relativePath, Path.of(source.relativePath)) != null) { - throw IllegalStateException("in-memory source must always be first " + - "(targetFile=$targetFile, source=${source.relativePath}, sources=${sources.joinToString()})") + throw IllegalStateException( + "in-memory source must always be first " + + "(targetFile=$targetFile, source=${source.relativePath}, sources=${sources.joinToString()})" + ) } packageIndexBuilder?.addFile(source.relativePath) @@ -194,34 +200,16 @@ internal suspend fun buildJar(targetFile: Path, is ZipSource -> { val sourceFile = source.file try { - //if (source.optimizeConfigId != null) { - // TraceManager.spanBuilder("optimize").setAttribute("library", source.optimizeConfigId).useWithoutActiveScope { - // val tempDir = optimizeLibraryContext!!.tempDir - // val suffix = System.nanoTime().toString(Character.MAX_RADIX) - // sourceFile = tempDir.resolve("${source.optimizeConfigId}-$suffix.jar") - // val mappingFile = tempDir.resolve("${source.optimizeConfigId}-${System.nanoTime().toString(Character.MAX_RADIX)}.jar") - // try { - // optimizeLibrary(name = source.optimizeConfigId, - // input = source.file, - // output = sourceFile, - // javaHome = optimizeLibraryContext.javaHome.toString(), - // mapping = mappingFile) - // zipCreator.file("${source.optimizeConfigId}.map.txt", mappingFile) - // } - // finally { - // Files.deleteIfExists(mappingFile) - // } - // } - //} - - handleZipSource(source = source, - sourceFile = sourceFile, - nativeFileHandler = nativeFileHandler, - uniqueNames = uniqueNames, - sources = sources, - packageIndexBuilder = packageIndexBuilder, - zipCreator = zipCreator, - compress = compress) + handleZipSource( + source = source, + sourceFile = sourceFile, + nativeFileHandler = nativeFileHandler, + uniqueNames = uniqueNames, + sources = sources, + packageIndexBuilder = packageIndexBuilder, + zipCreator = zipCreator, + compress = compress + ) } finally { @Suppress("KotlinConstantConditions") diff --git a/platform/core-impl/src/com/intellij/ide/plugins/PluginDescriptorLoader.kt b/platform/core-impl/src/com/intellij/ide/plugins/PluginDescriptorLoader.kt index c67edce2bf18..3fb9e25eff28 100644 --- a/platform/core-impl/src/com/intellij/ide/plugins/PluginDescriptorLoader.kt +++ b/platform/core-impl/src/com/intellij/ide/plugins/PluginDescriptorLoader.kt @@ -674,18 +674,22 @@ private fun loadCoreProductPlugin( override fun toString() = "product classpath" } - val raw = readModuleDescriptor(reader, - readContext = context, - pathResolver = pathResolver, - dataLoader = dataLoader, - includeBase = null, - readInto = null) - val descriptor = IdeaPluginDescriptorImpl(raw = raw, - path = Paths.get(PathManager.getLibPath()), - isBundled = true, - id = null, - moduleName = null, - useCoreClassLoader = useCoreClassLoader) + val raw = readModuleDescriptor( + reader, + readContext = context, + pathResolver = pathResolver, + dataLoader = dataLoader, + includeBase = null, + readInto = null, + ) + val descriptor = IdeaPluginDescriptorImpl( + raw = raw, + path = Paths.get(PathManager.getLibPath()), + isBundled = true, + id = null, + moduleName = null, + useCoreClassLoader = useCoreClassLoader, + ) context.debugData?.recordDescriptorPath(descriptor, raw, path) descriptor.readExternal(raw = raw, pathResolver = pathResolver, context = context, isSub = false, dataLoader = dataLoader) return descriptor