From 3e59c231a5f9b472592fe063265938b331580ff4 Mon Sep 17 00:00:00 2001 From: Derek Wickern Date: Fri, 29 Dec 2023 15:38:17 -0800 Subject: [PATCH] bat script: add -java-home option Parse arguments before verifying the Java installation --- .../packager/archetypes/scripts/bat-template | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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 1290584cd..925ba4d35 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 @@ -57,6 +57,11 @@ if defined BUNDLED_JVM ( if "%_JAVACMD%"=="" set _JAVACMD=java +rem if configuration files exist, prepend their contents to the script arguments so it can be processed by this runner +call :parse_config "%SCRIPT_CONF_FILE%" SCRIPT_CONF_ARGS + +call :process_args %SCRIPT_CONF_ARGS% %%* + rem Detect if this java is ok to use. for /F %%j in ('"%_JAVACMD%" -version 2^>^&1') do ( if %%~j==java set JAVAINSTALLED=1 @@ -86,11 +91,6 @@ if "%JAVAOK%"=="false" ( exit /B 1 ) -rem if configuration files exist, prepend their contents to the script arguments so it can be processed by this runner -call :parse_config "%SCRIPT_CONF_FILE%" SCRIPT_CONF_ARGS - -call :process_args %SCRIPT_CONF_ARGS% %%* - set _JAVA_OPTS=!_JAVA_OPTS! !_JAVA_PARAMS! if defined CUSTOM_MAIN_CLASS ( @@ -147,6 +147,13 @@ rem Processes incoming arguments and places them in appropriate global variables goto param_loop ) + if "!_TEST_PARAM!"=="-java-home" ( + set "JAVA_HOME=%~1" + set "_JAVACMD=%~1\bin\java.exe" + shift + goto param_loop + ) + if "!_TEST_PARAM:~0,2!"=="-J" ( rem strip -J prefix call set _TEST_PARAM=!_TEST_PARAM:~2!