From a2eb1ed17db645935ef594e396348ab3cb32376a Mon Sep 17 00:00:00 2001 From: AlexanderBartash Date: Sat, 5 Oct 2024 21:17:08 +0300 Subject: [PATCH] Fix issue #1777. IOB exception caused by "-XX:+AutoCreateSharedArchive" parameter not containing "=". --- CHANGELOG.md | 1 + .../platform/gradle/models/ProductInfo.kt | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 414b4209c5..9dbd6e2363 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Fixed issue #1778 by removing a hash of the absolute artifact path appended to the end of the version string. That hash made artifact version different on different PCs and also breaks Gradle dependency locking. - Add the missing `org.jetbrains.kotlin.platform.type=jvm` attribute to the `intellijPlatformRuntimeClasspath` configuration manually as it's not inherited from the `runtimeClasspath`. +- Fix #1777: IOB exception while running tests from Gradle. ## [2.1.0] diff --git a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/models/ProductInfo.kt b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/models/ProductInfo.kt index ef1040e130..ba7401dda3 100644 --- a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/models/ProductInfo.kt +++ b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/models/ProductInfo.kt @@ -173,21 +173,26 @@ internal fun ProductInfo.launchFor(architecture: String): ProductInfo.Launch { * * @receiver JVM argument with IDE home placeholder */ -internal fun String.resolveIdeHomeVariable(platformPath: Path) = - platformPath.pathString.let { - this - .replace("\$APP_PACKAGE", it) +internal fun String.resolveIdeHomeVariable(platformPath: Path): String { + val delimiters = "=" + if (!this.contains(delimiters)) { + return this + } + + return platformPath.pathString.let { + this.replace("\$APP_PACKAGE", it) .replace("\$IDE_HOME", it) .replace("%IDE_HOME%", it) .replace("Contents/Contents", "Contents") .let { entry -> - val (_, value) = entry.split("=") + val (_, value) = entry.split(delimiters) when { runCatching { Path(value).exists() }.getOrElse { false } -> entry else -> entry.replace("/Contents", "") } } } +} /** * Retrieves the [ProductInfo] for the IntelliJ Platform from the root directory.