Skip to content

Commit

Permalink
bat script: add -java-home option
Browse files Browse the repository at this point in the history
Parse arguments before verifying the Java installation
  • Loading branch information
dwickern committed Jan 4, 2024
1 parent ccced7a commit a95ddac
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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!
Expand Down

0 comments on commit a95ddac

Please sign in to comment.