From 753319a89d1a8fae8ad457db12e74f51654431f2 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Tue, 6 Mar 2018 00:29:41 +0300 Subject: [PATCH] Pill: Rewrite existing "idea.home.path" option if already set --- buildSrc/src/main/kotlin/pill/plugin.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/kotlin/pill/plugin.kt b/buildSrc/src/main/kotlin/pill/plugin.kt index 9a28b90a6a7..7f5f5ccb6c1 100644 --- a/buildSrc/src/main/kotlin/pill/plugin.kt +++ b/buildSrc/src/main/kotlin/pill/plugin.kt @@ -190,10 +190,15 @@ class JpsCompatiblePlugin : Plugin { getOrCreateChild("option", "name" to "VM_PARAMETERS").also { vmParams -> val ideaHomePathOptionKey = "-Didea.home.path=" val ideaHomePathOption = ideaHomePathOptionKey + platformDirProjectRelative - val existingOptions = vmParams.getAttributeValue("value", "").split(' ') - if (existingOptions.none { it.startsWith(ideaHomePathOptionKey) }) { - vmParams.setAttribute("value", (vmParams.getAttributeValue("value", "") + " " + ideaHomePathOption).trim()) - } + + val existingOptions = vmParams.getAttributeValue("value", "") + .split(' ') + .map { it.trim() } + .filter { it.isNotEmpty() && !it.startsWith(ideaHomePathOptionKey) } + + val newOptions = existingOptions.joinToString(" ") + " " + ideaHomePathOption + + vmParams.setAttribute("value", newOptions) } }