mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 11:53:49 +07:00
[maven] IDEA-340501 optimize bundled maven download
GitOrigin-RevId: f4ca277f2fbe5447b196e63e426ae8b3c27d64ab
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2d497bd66e
commit
6d3ddc8cc0
@@ -78,32 +78,40 @@ object BundledMavenDownloader {
|
||||
private suspend fun downloadMavenLibs(communityRoot: BuildDependenciesCommunityRoot, path: String, libs: List<String>): Path {
|
||||
val root = communityRoot.communityRoot.resolve(path)
|
||||
Files.createDirectories(root)
|
||||
val targetFileToUris = libs.associate { coordinates ->
|
||||
val split = coordinates.split(':')
|
||||
check(split.size == 3) {
|
||||
"Expected exactly 3 coordinates: $coordinates"
|
||||
}
|
||||
val file = root.resolve("${split[1]}-${split[2]}.jar")
|
||||
val uri = BuildDependenciesDownloader.getUriForMavenArtifact(
|
||||
mavenRepository = BuildDependenciesConstants.MAVEN_CENTRAL_URL,
|
||||
groupId = split[0],
|
||||
artifactId = split[1],
|
||||
version = split[2],
|
||||
packaging = "jar"
|
||||
)
|
||||
file to uri
|
||||
}
|
||||
|
||||
root.listDirectoryEntries().forEach { file ->
|
||||
if (!targetFileToUris.containsKey(file)) {
|
||||
BuildDependenciesUtil.deleteFileOrFolder(file)
|
||||
}
|
||||
}
|
||||
|
||||
val toDownload = targetFileToUris.filter { !Files.exists(it.key) }
|
||||
|
||||
if (toDownload.isEmpty()) return root
|
||||
|
||||
val targetToSourceFiles = coroutineScope {
|
||||
libs.map { coordinates ->
|
||||
toDownload.map { (targetFile, uri) ->
|
||||
async {
|
||||
val split = coordinates.split(':')
|
||||
check(split.size == 3) {
|
||||
"Expected exactly 3 coordinates: $coordinates"
|
||||
}
|
||||
val targetFile = root.resolve("${split[1]}-${split[2]}.jar")
|
||||
val uri = BuildDependenciesDownloader.getUriForMavenArtifact(
|
||||
mavenRepository = BuildDependenciesConstants.MAVEN_CENTRAL_URL,
|
||||
groupId = split[0],
|
||||
artifactId = split[1],
|
||||
version = split[2],
|
||||
packaging = "jar"
|
||||
)
|
||||
targetFile to downloadFileToCacheLocation(uri.toString(), communityRoot)
|
||||
}
|
||||
}
|
||||
}.asSequence().map { it.getCompleted() }.toMap()
|
||||
|
||||
root.listDirectoryEntries().forEach { file ->
|
||||
if (!targetToSourceFiles.containsKey(file)) {
|
||||
BuildDependenciesUtil.deleteFileOrFolder(file)
|
||||
}
|
||||
}
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
for (targetFile in targetToSourceFiles.keys) {
|
||||
val sourceFile = targetToSourceFiles.getValue(targetFile)
|
||||
|
||||
Reference in New Issue
Block a user