diff --git a/.idea/libraries/kaml.xml b/.idea/libraries/kaml.xml index ccbfd7cc952c..c1a2fc0ac358 100644 --- a/.idea/libraries/kaml.xml +++ b/.idea/libraries/kaml.xml @@ -1,12 +1,12 @@ - + - - 7e346b94d47fb4e4495ebd6161fd5c6d01659687e93c460bbfd320ba47bea852 + + bbb3901429952d8b0c5a11776262509142006d3e7e19001946c0393991dd7e10 - - 733e1347e3ec909e8a7ee199e48a64d0180569461b3bc08c8a6bb1335f5ce1bd + + e85b667e909e0b9eaee7ad0f0b36f47ba3a3a8824f1782718ec2f73d5f3ed741 8d0fd2aeb48d19dc49c563ebc00f274947e45f716c107535c12ead63decd688d @@ -19,14 +19,14 @@ - - + + - - + + diff --git a/.idea/libraries/ktor_client_okhttp.xml b/.idea/libraries/ktor_client_okhttp.xml deleted file mode 100644 index 209ee05086e4..000000000000 --- a/.idea/libraries/ktor_client_okhttp.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - a3c111c85eabb8149c485c275768d57cd96a05b595ca1946781c0d4c5fb1654a - - - - - - - - - - - - \ No newline at end of file diff --git a/lib/BUILD.bazel b/lib/BUILD.bazel index a9457dbf3375..d43498206ec5 100644 --- a/lib/BUILD.bazel +++ b/lib/BUILD.bazel @@ -4076,23 +4076,23 @@ jvm_import( java_library( name = "kaml", exports = [ - ":com_charleskorn_kaml-kaml-jvm-0_80_1_http_import", - ":it_krzeminski-snakeyaml-engine-kmp-jvm-3_1_1_http_import", + ":com_charleskorn_kaml-kaml-jvm-0_99_0_http_import", + ":it_krzeminski-snakeyaml-engine-kmp-jvm-3_2_1_http_import", ":net_thauvin_erik_urlencoder-urlencoder-lib-jvm-1_6_0_http_import", ], visibility = ["//visibility:public"] ) jvm_import( - name = "com_charleskorn_kaml-kaml-jvm-0_80_1_http_import", - jar = "@com_charleskorn_kaml-kaml-jvm-0_80_1_http//file", - source_jar = "@com_charleskorn_kaml-kaml-jvm-0_80_1_http//file" + name = "com_charleskorn_kaml-kaml-jvm-0_99_0_http_import", + jar = "@com_charleskorn_kaml-kaml-jvm-0_99_0_http//file", + source_jar = "@com_charleskorn_kaml-kaml-jvm-0_99_0_http//file" ) jvm_import( - name = "it_krzeminski-snakeyaml-engine-kmp-jvm-3_1_1_http_import", - jar = "@it_krzeminski-snakeyaml-engine-kmp-jvm-3_1_1_http//file", - source_jar = "@it_krzeminski-snakeyaml-engine-kmp-jvm-3_1_1_http//file" + name = "it_krzeminski-snakeyaml-engine-kmp-jvm-3_2_1_http_import", + jar = "@it_krzeminski-snakeyaml-engine-kmp-jvm-3_2_1_http//file", + source_jar = "@it_krzeminski-snakeyaml-engine-kmp-jvm-3_2_1_http//file" ) jvm_import( @@ -4955,13 +4955,6 @@ jvm_import( source_jar = "@io_ktor-ktor-client-mock-jvm-3_1_3_http//file" ) -jvm_import( - name = "ktor-client-okhttp", - jar = "@io_ktor-ktor-client-okhttp-jvm-3_1_3_http//file", - source_jar = "@io_ktor-ktor-client-okhttp-jvm-3_1_3_http//file", - visibility = ["//visibility:public"] -) - java_library( name = "ktor-network-tls", exports = [ @@ -5176,6 +5169,7 @@ java_library( ":io_coil-kt_coil3-coil-compose-jvm-3_2_0_http_import", ":io_coil-kt_coil3-coil-jvm-3_2_0_http_import", ":io_coil-kt_coil3-coil-core-jvm-3_2_0_http_import", + ":com_squareup_okio-okio-jvm-3_11_0_http_import", ":io_coil-kt_coil3-coil-compose-core-jvm-3_2_0_http_import", ], visibility = ["//visibility:public"] @@ -5199,6 +5193,12 @@ jvm_import( source_jar = "@io_coil-kt_coil3-coil-core-jvm-3_2_0_http//file" ) +jvm_import( + name = "com_squareup_okio-okio-jvm-3_11_0_http_import", + jar = "@com_squareup_okio-okio-jvm-3_11_0_http//file", + source_jar = "@com_squareup_okio-okio-jvm-3_11_0_http//file" +) + jvm_import( name = "io_coil-kt_coil3-coil-compose-core-jvm-3_2_0_http_import", jar = "@io_coil-kt_coil3-coil-compose-core-jvm-3_2_0_http//file", diff --git a/lib/MODULE.bazel b/lib/MODULE.bazel index 713de4718fcb..39f988191b86 100644 --- a/lib/MODULE.bazel +++ b/lib/MODULE.bazel @@ -6104,17 +6104,17 @@ http_file( ) http_file( - name = "com_charleskorn_kaml-kaml-jvm-0_80_1_http", - url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/com/charleskorn/kaml/kaml-jvm/0.80.1/kaml-jvm-0.80.1.jar", - sha256 = "7e346b94d47fb4e4495ebd6161fd5c6d01659687e93c460bbfd320ba47bea852", - downloaded_file_path = "kaml-jvm-0.80.1.jar" + name = "com_charleskorn_kaml-kaml-jvm-0_99_0_http", + url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/com/charleskorn/kaml/kaml-jvm/0.99.0/kaml-jvm-0.99.0.jar", + sha256 = "bbb3901429952d8b0c5a11776262509142006d3e7e19001946c0393991dd7e10", + downloaded_file_path = "kaml-jvm-0.99.0.jar" ) http_file( - name = "it_krzeminski-snakeyaml-engine-kmp-jvm-3_1_1_http", - url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/it/krzeminski/snakeyaml-engine-kmp-jvm/3.1.1/snakeyaml-engine-kmp-jvm-3.1.1.jar", - sha256 = "733e1347e3ec909e8a7ee199e48a64d0180569461b3bc08c8a6bb1335f5ce1bd", - downloaded_file_path = "snakeyaml-engine-kmp-jvm-3.1.1.jar" + name = "it_krzeminski-snakeyaml-engine-kmp-jvm-3_2_1_http", + url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/it/krzeminski/snakeyaml-engine-kmp-jvm/3.2.1/snakeyaml-engine-kmp-jvm-3.2.1.jar", + sha256 = "e85b667e909e0b9eaee7ad0f0b36f47ba3a3a8824f1782718ec2f73d5f3ed741", + downloaded_file_path = "snakeyaml-engine-kmp-jvm-3.2.1.jar" ) http_file( @@ -6125,17 +6125,17 @@ http_file( ) http_file( - name = "com_charleskorn_kaml-kaml-jvm-0_80_1-sources_http", - url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/com/charleskorn/kaml/kaml-jvm/0.80.1/kaml-jvm-0.80.1-sources.jar", - sha256 = "8fb6a48590169c34894f2bb41c9be86069cb4c2f6de5af7123753bf7f6b10818", - downloaded_file_path = "kaml-jvm-0.80.1-sources.jar" + name = "com_charleskorn_kaml-kaml-jvm-0_99_0-sources_http", + url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/com/charleskorn/kaml/kaml-jvm/0.99.0/kaml-jvm-0.99.0-sources.jar", + sha256 = "584a2625cfa0cdf8af0847efa8f22191f939350ea1c3909695cf89088f37bbf8", + downloaded_file_path = "kaml-jvm-0.99.0-sources.jar" ) http_file( - name = "it_krzeminski-snakeyaml-engine-kmp-jvm-3_1_1-sources_http", - url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/it/krzeminski/snakeyaml-engine-kmp-jvm/3.1.1/snakeyaml-engine-kmp-jvm-3.1.1-sources.jar", - sha256 = "8b256b041ae886c593e978db2367139bc47e612de4cf4346292cc8a8d32019c3", - downloaded_file_path = "snakeyaml-engine-kmp-jvm-3.1.1-sources.jar" + name = "it_krzeminski-snakeyaml-engine-kmp-jvm-3_2_1-sources_http", + url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/it/krzeminski/snakeyaml-engine-kmp-jvm/3.2.1/snakeyaml-engine-kmp-jvm-3.2.1-sources.jar", + sha256 = "7ba356923fecbce3756549d94022d6cad7bdae65f6c7ccafd6c600f144aaca12", + downloaded_file_path = "snakeyaml-engine-kmp-jvm-3.2.1-sources.jar" ) http_file( @@ -7195,20 +7195,6 @@ http_file( downloaded_file_path = "ktor-client-java-jvm-3.1.3-sources.jar" ) -http_file( - name = "io_ktor-ktor-client-okhttp-jvm-3_1_3_http", - url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/ktor/ktor-client-okhttp-jvm/3.1.3/ktor-client-okhttp-jvm-3.1.3.jar", - sha256 = "a3c111c85eabb8149c485c275768d57cd96a05b595ca1946781c0d4c5fb1654a", - downloaded_file_path = "ktor-client-okhttp-jvm-3.1.3.jar" -) - -http_file( - name = "io_ktor-ktor-client-okhttp-jvm-3_1_3-sources_http", - url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/ktor/ktor-client-okhttp-jvm/3.1.3/ktor-client-okhttp-jvm-3.1.3-sources.jar", - sha256 = "37b7709379bec327c8269c3f5020b16980ed2352057be80e93126542f113e672", - downloaded_file_path = "ktor-client-okhttp-jvm-3.1.3-sources.jar" -) - http_file( name = "io_ktor-ktor-serialization-kotlinx-json-jvm-3_1_3_http", url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/ktor/ktor-serialization-kotlinx-json-jvm/3.1.3/ktor-serialization-kotlinx-json-jvm-3.1.3.jar", @@ -7510,6 +7496,13 @@ http_file( downloaded_file_path = "coil-core-jvm-3.2.0.jar" ) +http_file( + name = "com_squareup_okio-okio-jvm-3_11_0_http", + url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/com/squareup/okio/okio-jvm/3.11.0/okio-jvm-3.11.0.jar", + sha256 = "2d22541a192f901a45c95274567d6957ac1ed613d49e41db4e5e5d86139cf022", + downloaded_file_path = "okio-jvm-3.11.0.jar" +) + http_file( name = "io_coil-kt_coil3-coil-compose-core-jvm-3_2_0_http", url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/coil-kt/coil3/coil-compose-core-jvm/3.2.0/coil-compose-core-jvm-3.2.0.jar", @@ -7538,6 +7531,13 @@ http_file( downloaded_file_path = "coil-core-jvm-3.2.0-sources.jar" ) +http_file( + name = "com_squareup_okio-okio-jvm-3_11_0-sources_http", + url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/com/squareup/okio/okio-jvm/3.11.0/okio-jvm-3.11.0-sources.jar", + sha256 = "4cc11c760166d43da9653a5c27ddbf58a510bb8f35ff1aa3a1676206e56a0e4e", + downloaded_file_path = "okio-jvm-3.11.0-sources.jar" +) + http_file( name = "io_coil-kt_coil3-coil-compose-core-jvm-3_2_0-sources_http", url = "https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/io/coil-kt/coil3/coil-compose-core-jvm/3.2.0/coil-compose-core-jvm-3.2.0-sources.jar", diff --git a/libraries/coil/intellij.libraries.coil.iml b/libraries/coil/intellij.libraries.coil.iml index 356139775fe0..c8cbc78edf3a 100644 --- a/libraries/coil/intellij.libraries.coil.iml +++ b/libraries/coil/intellij.libraries.coil.iml @@ -21,10 +21,8 @@ - - - + @@ -93,6 +91,9 @@ 2c64e5a3be4c59a2bf1ead26891cd9c455c37a2802d258ea50a960e7dd1e121a + + 2d22541a192f901a45c95274567d6957ac1ed613d49e41db4e5e5d86139cf022 + a74b96cb179fe8f872d4e9f03468e0477d32787e9b6430a9d137aafb76012a60 @@ -101,7 +102,6 @@ - @@ -109,18 +109,21 @@ + + + diff --git a/libraries/coil/module-content.yaml b/libraries/coil/module-content.yaml index 92f25490f19e..380c110804b9 100644 --- a/libraries/coil/module-content.yaml +++ b/libraries/coil/module-content.yaml @@ -11,4 +11,5 @@ - name: $MAVEN_REPOSITORY$/io/coil-kt/coil3/coil-compose-jvm/3/coil-compose-jvm-3.jar - name: $MAVEN_REPOSITORY$/io/coil-kt/coil3/coil-jvm/3/coil-jvm-3.jar - name: $MAVEN_REPOSITORY$/io/coil-kt/coil3/coil-core-jvm/3/coil-core-jvm-3.jar + - name: $MAVEN_REPOSITORY$/com/squareup/okio/okio-jvm/3/okio-jvm-3.jar - name: $MAVEN_REPOSITORY$/io/coil-kt/coil3/coil-compose-core-jvm/3/coil-compose-core-jvm-3.jar \ No newline at end of file diff --git a/platform/build-scripts/downloader/BUILD.bazel b/platform/build-scripts/downloader/BUILD.bazel index 00d377a90ed4..931acf29aac1 100644 --- a/platform/build-scripts/downloader/BUILD.bazel +++ b/platform/build-scripts/downloader/BUILD.bazel @@ -18,8 +18,6 @@ jvm_library( "@lib//:opentelemetry", "@lib//:opentelemetry-semconv", "@lib//:opentelemetry-extension-kotlin", - "@lib//:ktor-client-okhttp", - "@lib//:okhttp", "//libraries/hash4j", "//libraries/ktor/client", "//libraries/ktor/io", diff --git a/platform/build-scripts/downloader/intellij.platform.buildScripts.downloader.iml b/platform/build-scripts/downloader/intellij.platform.buildScripts.downloader.iml index 508d3588a14a..b52bb4f35701 100644 --- a/platform/build-scripts/downloader/intellij.platform.buildScripts.downloader.iml +++ b/platform/build-scripts/downloader/intellij.platform.buildScripts.downloader.iml @@ -33,8 +33,6 @@ - - diff --git a/platform/build-scripts/downloader/src/BuildDependenciesJps.kt b/platform/build-scripts/downloader/src/BuildDependenciesJps.kt index 1afd38bd95ec..96b7b556ed81 100644 --- a/platform/build-scripts/downloader/src/BuildDependenciesJps.kt +++ b/platform/build-scripts/downloader/src/BuildDependenciesJps.kt @@ -2,7 +2,6 @@ package org.jetbrains.intellij.build import kotlinx.coroutines.runBlocking -import okio.Path.Companion.toPath import org.jetbrains.annotations.ApiStatus import org.jetbrains.intellij.build.dependencies.BuildDependenciesCommunityRoot import org.jetbrains.intellij.build.dependencies.BuildDependenciesDownloader.Credentials @@ -32,7 +31,7 @@ object BuildDependenciesJps { val allModules = modules.getChildElements("module") .mapNotNull { it.getAttribute("filepath") } val moduleFile = allModules.singleOrNull { it.endsWith("/${moduleName}.iml") } - ?.replace("\$PROJECT_DIR\$", getSystemIndependentPath(projectHome)) + ?.replace($$"$PROJECT_DIR$", getSystemIndependentPath(projectHome)) ?: error("Unable to find module '$moduleName' in $modulesXml") val modulePath = Path.of(moduleFile) check(Files.exists(modulePath)) { @@ -65,11 +64,11 @@ object BuildDependenciesJps { .map { it .removePrefix("jar:/") - .replace("\$MAVEN_REPOSITORY\$", "") + .replace($$"$MAVEN_REPOSITORY$", "") .trim('!', '/') } .map { relativePath -> - val fileUrl = "file://\$MAVEN_REPOSITORY\$/${relativePath}" + val fileUrl = $$"file://$MAVEN_REPOSITORY$/$${relativePath}" val remoteUrl = mavenRepositoryUrl.trimEnd('/') + "/${relativePath}" val localMavenFile = Path.of(getMavenRepositoryPath()).resolve(relativePath) diff --git a/platform/build-scripts/downloader/src/ktor.kt b/platform/build-scripts/downloader/src/ktor.kt index 1e0bb740da0c..14dfbe3c3af8 100644 --- a/platform/build-scripts/downloader/src/ktor.kt +++ b/platform/build-scripts/downloader/src/ktor.kt @@ -6,7 +6,7 @@ package org.jetbrains.intellij.build import io.ktor.client.HttpClient import io.ktor.client.HttpClientConfig import io.ktor.client.call.body -import io.ktor.client.engine.okhttp.OkHttp +import io.ktor.client.engine.java.Java import io.ktor.client.plugins.HttpRequestRetry import io.ktor.client.plugins.HttpTimeout import io.ktor.client.plugins.UserAgent @@ -28,12 +28,8 @@ import io.ktor.client.statement.bodyAsChannel import io.ktor.client.statement.bodyAsText import io.ktor.http.HttpHeaders import io.ktor.utils.io.ByteReadChannel -import io.ktor.utils.io.ByteWriteChannel -import io.ktor.utils.io.copyAndClose import io.ktor.utils.io.copyTo -import io.ktor.utils.io.core.use import io.ktor.utils.io.jvm.nio.writeSuspendSession -import io.ktor.utils.io.reader import io.ktor.utils.io.writer import io.opentelemetry.api.common.AttributeKey import io.opentelemetry.api.common.Attributes @@ -45,7 +41,6 @@ import io.opentelemetry.extension.kotlin.asContextElement import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext import org.jetbrains.intellij.build.dependencies.BuildDependenciesCommunityRoot @@ -71,13 +66,9 @@ const val SPACE_REPO_HOST: String = "packages.jetbrains.team" private val httpClient = SynchronizedClearableLazy { // HttpTimeout is not used - CIO engine handles that - HttpClient(OkHttp) { + HttpClient(Java) { expectSuccess = true - engine { - clientCacheSize = 0 - } - install(HttpTimeout) { requestTimeoutMillis = 2.hours.inWholeMilliseconds } @@ -252,14 +243,15 @@ suspend fun downloadFileToCacheLocation(url: String, communityRoot: BuildDepende }) } -private fun downloadFileIsRetryAllowed(e: Exception): Boolean = - when (e) { +private fun downloadFileIsRetryAllowed(e: Exception): Boolean { + return when (e) { is SocketException if e.message?.contains("Operation not permitted") == true -> { // Most likely, in a Bazel sandbox where network access was disabled, retry is useless false } else -> true } +} private suspend fun downloadFileToCacheLocation( url: String, @@ -274,15 +266,18 @@ private suspend fun downloadFileToCacheLocation( lock.lock() try { if (Files.exists(target)) { - Span.current().addEvent("use asset from cache", Attributes.of( + Span.current().addEvent( + "use asset from cache", Attributes.of( AttributeKey.stringKey("url"), url, AttributeKey.stringKey("target"), targetPath, - )) + ) + ) // update file modification time to maintain FIFO caches, i.e., in a persistent cache dir on TeamCity agent try { Files.setLastModifiedTime(target, FileTime.from(Instant.now())) - } catch (e: IOException) { + } + catch (e: IOException) { Span.current().addEvent("update asset file modification time failed: $e") } return target @@ -293,8 +288,7 @@ private suspend fun downloadFileToCacheLocation( return spanBuilder("download").setAttribute("url", url).setAttribute("target", targetPath).useWithScope { retryWithExponentialBackOff(isRetryAllowed = { e -> downloadFileIsRetryAllowed(e) }) { // save to the same disk to ensure that move will be atomic and not as a copy - val tempFile = target.parent - .resolve("${target.fileName}-${(Instant.now().epochSecond - 1634886185).toString(36)}-${Instant.now().nano.toString(36)}".take(255)) + val tempFile = target.parent.resolve("${target.fileName}-${(Instant.now().epochSecond - 1634886185).toString(36)}-${Instant.now().nano.toString(36)}".take(255)) Files.deleteIfExists(tempFile) try { // each io.ktor.client.HttpClient.config call creates a new client @@ -373,13 +367,17 @@ private suspend fun downloadFileToCacheLocation( } suspend fun downloadFileWithoutCaching(url: String, tempFile: Path) { - doDownloadFileWithoutCaching(httpClient.get(), url, tempFile) + doDownloadFileWithoutCaching(client = httpClient.get(), url = url, file = tempFile) } +// https://github.com/ktorio/ktor/issues/5127 +// https://github.com/ktorio/ktor/pull/5128 private suspend fun doDownloadFileWithoutCaching(client: HttpClient, url: String, file: Path): HttpResponse { return client.prepareGet(url).execute { - coroutineScope { - it.bodyAsChannel().copyAndClose(writeChannel(file)) + withContext(Dispatchers.IO) { + FileChannel.open(file, WRITE_NEW_OPERATION).use { fileChannel -> + it.bodyAsChannel().copyTo(fileChannel) + } } it } @@ -410,11 +408,3 @@ fun CoroutineScope.readChannel(file: Path): ByteReadChannel { } private val WRITE_NEW_OPERATION = EnumSet.of(StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW) - -private fun CoroutineScope.writeChannel(file: Path): ByteWriteChannel { - return reader(CoroutineName("file-writer") + Dispatchers.IO, autoFlush = true) { - FileChannel.open(file, WRITE_NEW_OPERATION).use { fileChannel -> - channel.copyTo(fileChannel) - } - }.channel -} diff --git a/platform/jps-bootstrap/pom.xml b/platform/jps-bootstrap/pom.xml index e94b71cd7567..04bfe9a3c00d 100644 --- a/platform/jps-bootstrap/pom.xml +++ b/platform/jps-bootstrap/pom.xml @@ -45,11 +45,6 @@ ktor-client-java-jvm 3.1.3 - - io.ktor - ktor-client-okhttp-jvm - 3.1.3 - io.ktor ktor-client-encoding-jvm diff --git a/python/BUILD.bazel b/python/BUILD.bazel index 805864bbe68b..d925c9e099ba 100644 --- a/python/BUILD.bazel +++ b/python/BUILD.bazel @@ -347,7 +347,6 @@ jvm_library( "@lib//:com-jetbrains-fus-reporting-ap-validation-all", "//libraries/http-client", "//libraries/commons/lang3", - "@lib//:kaml", "//python/impl.helperLocator:community-helpersLocator", "//python/python-exec-service/execService.python", "//python/interpreters", diff --git a/python/intellij.python.community.impl.iml b/python/intellij.python.community.impl.iml index 44d5bd181a66..24f92f55a91e 100644 --- a/python/intellij.python.community.impl.iml +++ b/python/intellij.python.community.impl.iml @@ -184,7 +184,6 @@ - diff --git a/python/pluginCore/plugin-content.yaml b/python/pluginCore/plugin-content.yaml index 3cf20db4dcbb..7fba72a1c437 100644 --- a/python/pluginCore/plugin-content.yaml +++ b/python/pluginCore/plugin-content.yaml @@ -43,12 +43,6 @@ files: - name: $MAVEN_REPOSITORY$/com/google/code/findbugs/jsr305/3/jsr305-3.jar reason: <- intellij.python.community.impl - - name: kaml - files: - - name: $MAVEN_REPOSITORY$/com/charleskorn/kaml/kaml-jvm/0/kaml-jvm-0.jar - - name: $MAVEN_REPOSITORY$/it/krzeminski/snakeyaml-engine-kmp-jvm/3/snakeyaml-engine-kmp-jvm-3.jar - - name: $MAVEN_REPOSITORY$/net/thauvin/erik/urlencoder/urlencoder-lib-jvm/1/urlencoder-lib-jvm-1.jar - reason: <- intellij.python.community.impl - name: libthrift files: - name: $MAVEN_REPOSITORY$/org/apache/thrift/libthrift/0/libthrift-0.jar diff --git a/python/src/com/jetbrains/python/packaging/conda/environmentYml/format/CondaEnvironmentYmlParser.kt b/python/src/com/jetbrains/python/packaging/conda/environmentYml/format/CondaEnvironmentYmlParser.kt index 0f474ccfad79..28cf387a273e 100644 --- a/python/src/com/jetbrains/python/packaging/conda/environmentYml/format/CondaEnvironmentYmlParser.kt +++ b/python/src/com/jetbrains/python/packaging/conda/environmentYml/format/CondaEnvironmentYmlParser.kt @@ -1,7 +1,9 @@ // Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.jetbrains.python.packaging.conda.environmentYml.format -import com.charleskorn.kaml.* +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory import com.intellij.openapi.application.runReadAction import com.intellij.openapi.diagnostic.thisLogger import com.intellij.openapi.fileEditor.FileDocumentManager @@ -14,7 +16,6 @@ import com.jetbrains.python.packaging.parser.RequirementsParserHelper import com.jetbrains.python.packaging.requirement.PyRequirementRelation import org.jetbrains.annotations.ApiStatus - @ApiStatus.Internal object CondaEnvironmentYmlParser { fun readNameFromFile(file: VirtualFile): String? = readFieldFromFile(file, "name") @@ -23,10 +24,10 @@ object CondaEnvironmentYmlParser { @RequiresBackgroundThread private fun readFieldFromFile(file: VirtualFile, field: String): String? = runReadAction { val text = FileDocumentManager.getInstance().getDocument(file)?.text ?: return@runReadAction null - val yaml = Yaml(configuration = YamlConfiguration(strictMode = false)) - val environment: YamlMap = yaml.parseToYamlNode(text).yamlMap + val mapper = ObjectMapper(YAMLFactory()) + val environment: JsonNode = mapper.readTree(text) - environment.get(field)?.yamlScalar?.content + environment.path(field).asText().takeIf { it.isNotEmpty() } } fun fromFile(file: VirtualFile): List? { @@ -39,28 +40,30 @@ object CondaEnvironmentYmlParser { private fun readDeps(file: VirtualFile): List { val text = FileDocumentManager.getInstance().getDocument(file)?.text ?: return emptyList() - val yaml = Yaml(configuration = YamlConfiguration(strictMode = false)) - val environment: YamlMap = yaml.parseToYamlNode(text).yamlMap + val mapper = ObjectMapper(YAMLFactory()) + val environment: JsonNode = mapper.readTree(text) val result = mutableListOf() - val dependencies = environment.get("dependencies") ?: return emptyList() - for (dependency in dependencies.items) { - when (dependency) { - is YamlScalar -> { - val dep = dependency.yamlScalar.content + val dependencies = environment.path("dependencies") + if (!dependencies.isArray) return emptyList() + + for (dependency in dependencies) { + when { + dependency.isTextual -> { + val dep = dependency.asText() val parsed = parseCondaDep(dep) ?: continue result.add(parsed) } // Pip section (map with "pip" key) - is YamlMap -> { - val pipList = dependency.yamlMap.get("pip") ?: continue + dependency.isObject -> { + val pipList = dependency.path("pip") + if (!pipList.isArray) continue val pipListDeps = parsePipListDeps(pipList, file) result.addAll(pipListDeps) } - else -> {} } } return result @@ -114,8 +117,8 @@ object CondaEnvironmentYmlParser { return PyRequirementParser.fromLine("$packageName==$version") } - private fun parsePipListDeps(pipList: YamlList, file: VirtualFile): List { - val pipText = pipList.items.filterIsInstance().joinToString("\n") { it.yamlScalar.content } + private fun parsePipListDeps(pipList: JsonNode, file: VirtualFile): List { + val pipText = pipList.filter { it.isTextual }.joinToString("\n") { it.asText() } return PyRequirementParser.fromText(pipText, file, mutableSetOf()) } }