diff --git a/java/idea-ui/src/com/intellij/internal/DumpJdkIndexStarter.kt b/java/idea-ui/src/com/intellij/internal/DumpJdkIndexStarter.kt index d806f523ee5e..a1e098606c57 100644 --- a/java/idea-ui/src/com/intellij/internal/DumpJdkIndexStarter.kt +++ b/java/idea-ui/src/com/intellij/internal/DumpJdkIndexStarter.kt @@ -30,7 +30,6 @@ class DumpJdkIndexStarter : IndexesStarterBase("dump-jdk-index") { val jdkHomeKey = "jdk-home" val tempKey = "temp" val outputKey = "output" - val baseUrlKey = "base-url" println("") println(" [idea] ${commandName} ... (see keys below)") @@ -41,13 +40,11 @@ class DumpJdkIndexStarter : IndexesStarterBase("dump-jdk-index") { println(" (!) it will be cleared by the tool") println(" --$outputKey= --- location of the indexes CDN image,") println(" it will be updated with new data") - println(" [--$baseUrlKey=] --- CDN base URL for index.json files") println("") println("") println("") val nameHint = args.arg(nameHintKey, "").nullize(true) - val baseUrl = args.arg(baseUrlKey, "").nullize(true)?.trim()?.trimEnd('/') val jdkHome = args.argFile(jdkHomeKey, System.getProperty("java.home")) val tempDir = args.argFile(tempKey).recreateDir() val outputDir = args.argFile(outputKey).apply { mkdirs() } @@ -152,12 +149,9 @@ class DumpJdkIndexStarter : IndexesStarterBase("dump-jdk-index") { val indexDir = (outputDir / indexKind / hash).apply { mkdirs() } fun indexFile(nameSuffix: String) = indexDir / "${indexChunk.name}-${infraVersion.weakVersionHash}$nameSuffix" - FileUtil.copy(indexZipXZ, indexFile(".ijx")) + FileUtil.copy(indexZipXZ, indexFile(".ijx.xz")) FileUtil.writeToFile(indexFile(".json"), indexMetadata) FileUtil.writeToFile(indexFile(".sha256"), indexZipXZ.sha256()) - if (baseUrl != null) { - UpdateIndexesLayoutStarter.rebuildIndexForHashDir(indexDir, baseUrl) - } exitProcess(0) } diff --git a/java/idea-ui/src/com/intellij/internal/UpdateIndexesLayoutStarter.kt b/java/idea-ui/src/com/intellij/internal/UpdateIndexesLayoutStarter.kt deleted file mode 100644 index b1e2182a8cc8..000000000000 --- a/java/idea-ui/src/com/intellij/internal/UpdateIndexesLayoutStarter.kt +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -package com.intellij.internal - -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.databind.node.ObjectNode -import com.intellij.openapi.util.io.FileUtil -import java.io.File -import kotlin.system.exitProcess - -class UpdateIndexesLayoutStarter : IndexesStarterBase("update-index-layout") { - override fun mainImpl(args: Array) { - println("Update indexes layout and generates all necessary index files") - println("usage:") - println(" [idea] $commandName --output= --base-url=") - println() - - val outputDir = args.argFile("output") - val baseUrl = args.arg("base-url") - - if (!outputDir.isDirectory) { - println("Directory $outputDir does not exist or is a file. Nothing to do.") - exitProcess(2) - } - - val allHashes = runAndCatchNotNull("failed to list $outputDir") { - outputDir.listFiles() - }.filter { it.isDirectory }.sortedBy { it.name } - - LOG.info("Detected ${allHashes.size} folders to index...") - - for (hash in allHashes) { - LOG.info("Updating ${hash.name}...") - rebuildIndexForHashDir(hash, baseUrl) - } - } - - companion object { - fun rebuildIndexForHashDir(hashDir: File, baseUrl: String) { - val hashCode = hashDir.name - - data class IndexFile( - val indexFile: File, - val metadataFile: File, - val sha256File: File - ) { - val metadata by lazy { metadataFile.readBytes() } - val sha256 by lazy { sha256File.readText().trim() } - - val indexFileName get() = indexFile.name - } - - val indexes: List = (hashDir.listFiles()?.toList() ?: listOf()) - .groupBy{ it.nameWithoutExtension } - .mapNotNull { (_, group) -> - val indexFile = group.firstOrNull { it.path.endsWith(".ijx") } ?: return@mapNotNull null - val metadataFile = group.firstOrNull { it.path.endsWith(".json") } ?: return@mapNotNull null - val shaFile = group.firstOrNull { it.path.endsWith(".sha256") } ?: return@mapNotNull null - IndexFile(indexFile, metadataFile, shaFile) - }.sortedBy { it.indexFileName } - - val om = ObjectMapper() - val root = om.createObjectNode() - - root.put("list_version", "1") - val entries = root.putArray("entries") - - for (idx in indexes) { - val entry = entries.addObject() - - entry.put("url", "$baseUrl/$hashCode/${idx.indexFileName}") - entry.put("sha256", idx.sha256) - entry.set("metadata", om.readTree(idx.metadata)) - } - - val listData = om.writerWithDefaultPrettyPrinter().writeValueAsBytes(root) - FileUtil.writeToFile(File(hashDir, "index.json"), listData) - } - } -}