@@ -57,6 +57,11 @@ if defined BUNDLED_JVM (
57
57
58
58
if "%_JAVACMD%"=="" set _JAVACMD=java
59
59
60
+ rem if configuration files exist, prepend their contents to the script arguments so it can be processed by this runner
61
+ call :parse_config "%SCRIPT_CONF_FILE%" SCRIPT_CONF_ARGS
62
+
63
+ call :process_args %SCRIPT_CONF_ARGS% %%*
64
+
60
65
rem Detect if this java is ok to use.
61
66
for /F %%j in ('"%_JAVACMD%" -version 2^>^&1') do (
62
67
if %%~j==java set JAVAINSTALLED=1
@@ -86,11 +91,6 @@ if "%JAVAOK%"=="false" (
86
91
exit /B 1
87
92
)
88
93
89
- rem if configuration files exist, prepend their contents to the script arguments so it can be processed by this runner
90
- call :parse_config "%SCRIPT_CONF_FILE%" SCRIPT_CONF_ARGS
91
-
92
- call :process_args %SCRIPT_CONF_ARGS% %%*
93
-
94
94
set _JAVA_OPTS=!_JAVA_OPTS! !_JAVA_PARAMS!
95
95
96
96
if defined CUSTOM_MAIN_CLASS (
@@ -135,23 +135,36 @@ exit /B 0
135
135
rem Processes incoming arguments and places them in appropriate global variables
136
136
:process_args
137
137
:param_loop
138
- call set _PARAM1=%%1
139
- set "_TEST_PARAM=%~1"
138
+ shift
139
+ call set _PARAM1=%%0
140
+ set "_TEST_PARAM=%~0"
140
141
141
142
if ["!_PARAM1!"]==[""] goto param_afterloop
142
143
144
+ if "!_TEST_PARAM!"=="-main" (
145
+ call set CUSTOM_MAIN_CLASS=%%1
146
+ shift
147
+ goto param_loop
148
+ )
143
149
144
- rem ignore arguments that do not start with '-'
145
- if "%_TEST_PARAM:~0,1%"=="-" goto param_java_check
146
- set _APP_ARGS=!_APP_ARGS! !_PARAM1!
147
- shift
148
- goto param_loop
150
+ if "!_TEST_PARAM!"=="-java-home" (
151
+ set "JAVA_HOME=%~1"
152
+ set "_JAVACMD=%~1\bin\java.exe"
153
+ shift
154
+ goto param_loop
155
+ )
149
156
150
- :param_java_check
151
157
if "!_TEST_PARAM:~0,2!"=="-J" (
152
158
rem strip -J prefix
153
- set _JAVA_PARAMS=!_JAVA_PARAMS! !_TEST_PARAM:~2!
154
- shift
159
+ call set _TEST_PARAM=!_TEST_PARAM:~2!
160
+ if not "!_TEST_PARAM:~0,5!" == "-XX:+" if not "!_TEST_PARAM:~0,5!" == "-XX:-" if "!_TEST_PARAM:~0,3!" == "-XX" (
161
+ rem special handling for -J-XX since '=' gets parsed away
162
+ for /F "delims== tokens=1,*" %%G in ("!_TEST_PARAM!") DO (
163
+ call set _TEST_PARAM=!_TEST_PARAM!=%%1
164
+ shift
165
+ )
166
+ )
167
+ set _JAVA_PARAMS=!_JAVA_PARAMS! !_TEST_PARAM!
155
168
goto param_loop
156
169
)
157
170
@@ -160,22 +173,18 @@ rem Processes incoming arguments and places them in appropriate global variables
160
173
for /F "delims== tokens=1,*" %%G in ("!_TEST_PARAM!") DO (
161
174
if not ["%%H"] == [""] (
162
175
set _JAVA_PARAMS=!_JAVA_PARAMS! !_PARAM1!
163
- ) else if [%2 ] neq [] (
176
+ ) else if [%1 ] neq [] (
164
177
rem it was a normal property: -Dprop=42 or -Drop="42"
165
- call set _PARAM1=%%1 =%%2
178
+ call set _PARAM1=%%0 =%%1
166
179
set _JAVA_PARAMS=!_JAVA_PARAMS! !_PARAM1!
167
180
shift
168
181
)
169
182
)
170
- ) else (
171
- if "!_TEST_PARAM!"=="-main" (
172
- call set CUSTOM_MAIN_CLASS=%%2
173
- shift
174
- ) else (
175
- set _APP_ARGS=!_APP_ARGS! !_PARAM1!
176
- )
183
+ goto param_loop
177
184
)
178
- shift
185
+
186
+ set _APP_ARGS=!_APP_ARGS! !_PARAM1!
187
+
179
188
goto param_loop
180
189
:param_afterloop
181
190
0 commit comments