From ccced7a9123d842e4ca1ff540d6b524d08dc9710 Mon Sep 17 00:00:00 2001 From: Derek Wickern Date: Fri, 29 Dec 2023 15:12:34 -0800 Subject: [PATCH] bat script: fix parsing of -J-XX: jvm args --- .../sbt/packager/archetypes/scripts/bat-template | 10 +++++++++- src/sbt-test/windows/test-bat-template/build.sbt | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/bat-template b/src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/bat-template index e25165f24..5ba105e9d 100644 --- a/src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/bat-template +++ b/src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/bat-template @@ -149,7 +149,15 @@ rem Processes incoming arguments and places them in appropriate global variables if "!_TEST_PARAM:~0,2!"=="-J" ( rem strip -J prefix - set _JAVA_PARAMS=!_JAVA_PARAMS! !_TEST_PARAM:~2! + call set _TEST_PARAM=!_TEST_PARAM:~2! + if not "!_TEST_PARAM:~0,5!" == "-XX:+" if not "!_TEST_PARAM:~0,5!" == "-XX:-" if "!_TEST_PARAM:~0,3!" == "-XX" ( + rem special handling for -J-XX since '=' gets parsed away + for /F "delims== tokens=1,*" %%G in ("!_TEST_PARAM!") DO ( + call set _TEST_PARAM=!_TEST_PARAM!=%%1 + shift + ) + ) + set _JAVA_PARAMS=!_JAVA_PARAMS! !_TEST_PARAM! goto param_loop ) diff --git a/src/sbt-test/windows/test-bat-template/build.sbt b/src/sbt-test/windows/test-bat-template/build.sbt index b2395a059..a0634e67f 100644 --- a/src/sbt-test/windows/test-bat-template/build.sbt +++ b/src/sbt-test/windows/test-bat-template/build.sbt @@ -100,6 +100,12 @@ TaskKey[Unit]("checkScript") := { "arg #0 is [first]\narg #1 is [-XX]\narg #2 is [last]\nproperty(test.hoge) is [huga]\nvmarg #0 is [-Dtest.hoge=huga]\nvmarg #1 is [-Xms6m]\nSUCCESS!", Map("show-vmargs" -> "true") ) + checkOutput( + "with -J-XX java-opts", + Seq("-J-XX:+UseG1GC", "-J-XX:-UnlockExperimentalVMOptions", "-J-XX:MaxGCPauseMillis=500"), + "vmarg #0 is [-XX:+UseG1GC]\nvmarg #1 is [-XX:-UnlockExperimentalVMOptions]\nvmarg #2 is [-XX:MaxGCPauseMillis=500]\nSUCCESS!", + Map("show-vmargs" -> "true") + ) checkOutput( "include space", Seq("""-Dtest.hoge=C:\Program Files\Java""", """"C:\Program Files\Java""""),