Skip to content

Commit 3420773

Browse files
authored
chore: Fix build.bat syntax errors (#1286)
1 parent 8e91c99 commit 3420773

File tree

1 file changed

+46
-28
lines changed

1 file changed

+46
-28
lines changed

build.bat

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ goto :usage
3232
echo usage: %~n0 ^<command^> [options]
3333
echo.
3434
echo Available commands:
35-
echo demo ^<type^> Run a demo (gogo, repl, password)
35+
echo demo ^<type^> Run a demo ^(gogo, repl, password^)
3636
echo example ^<className^> Run an example from org.jline.demo.examples
3737
echo rebuild Clean and install the project
3838
echo license-check Check license headers
@@ -65,16 +65,16 @@ if "%demo_type%"=="" (
6565
echo jansi Add Jansi support
6666
echo jna Add JNA support
6767
echo verbose Enable verbose logging
68-
echo ffm Enable Foreign Function Memory (preview)
68+
echo ffm Enable Foreign Function Memory ^(preview^)
6969
echo.
7070
echo Gogo-specific options:
7171
echo ssh Add SSH support
7272
echo telnet Add Telnet support
73-
echo remote Add remote support (SSH and Telnet)
73+
echo remote Add remote support ^(SSH and Telnet^)
7474
echo.
7575
echo Password-specific options:
76-
echo --mask=X Use X as the mask character (default: *)
77-
echo Use --mask= (empty) for no masking
76+
echo --mask=X Use X as the mask character ^(default: *^)
77+
echo Use --mask= ^(empty^) for no masking
7878
exit /b 1
7979
)
8080

@@ -152,27 +152,27 @@ if "%~1"=="--help" (
152152
echo --help Show this help message
153153
echo ssh Add SSH support
154154
echo telnet Add Telnet support
155-
echo remote Add remote support (SSH and Telnet)
155+
echo remote Add remote support ^(SSH and Telnet^)
156156
echo debug Enable remote debugging
157157
echo debugs Enable remote debugging with suspend
158158
echo jansi Add Jansi support
159159
echo jna Add JNA support
160160
echo verbose Enable verbose logging
161-
echo ffm Enable Foreign Function Memory (preview)
161+
echo ffm Enable Foreign Function Memory ^(preview^)
162162
echo.
163163
echo To test with a dumb terminal, use: set TERM=dumb ^& %~n0 demo gogo
164164
) else if "%demo_type%"=="password" (
165165
echo Usage: %~n0 demo password [options]
166166
echo Options:
167167
echo --help Show this help message
168-
echo --mask=X Use X as the mask character (default: *)
169-
echo Use --mask= (empty) for no masking
168+
echo --mask=X Use X as the mask character ^(default: *^)
169+
echo Use --mask= ^(empty^) for no masking
170170
echo debug Enable remote debugging
171171
echo debugs Enable remote debugging with suspend
172172
echo jansi Add Jansi support
173173
echo jna Add JNA support
174174
echo verbose Enable verbose logging
175-
echo ffm Enable Foreign Function Memory (preview)
175+
echo ffm Enable Foreign Function Memory ^(preview^)
176176
echo.
177177
echo To test with a dumb terminal, use: set TERM=dumb ^& %~n0 demo password
178178
) else if "%demo_type%"=="consoleui" (
@@ -181,10 +181,10 @@ if "%~1"=="--help" (
181181
echo --help Show this help message
182182
echo debug Enable remote debugging
183183
echo debugs Enable remote debugging with suspend
184-
echo jansi Add Jansi support (recommended for Windows)
185-
echo jna Add JNA support (alternative for Windows)
184+
echo jansi Add Jansi support ^(recommended for Windows^)
185+
echo jna Add JNA support ^(alternative for Windows^)
186186
echo verbose Enable verbose logging
187-
echo ffm Enable Foreign Function Memory (preview)
187+
echo ffm Enable Foreign Function Memory ^(preview^)
188188
echo.
189189
echo Note: On Windows, either Jansi or JNA library must be included in classpath.
190190
echo To test with a dumb terminal, use: set TERM=dumb ^& %~n0 demo consoleui
@@ -197,7 +197,7 @@ if "%~1"=="--help" (
197197
echo jansi Add Jansi support
198198
echo jna Add JNA support
199199
echo verbose Enable verbose logging
200-
echo ffm Enable Foreign Function Memory (preview)
200+
echo ffm Enable Foreign Function Memory ^(preview^)
201201
echo.
202202
echo To test with a dumb terminal, use: set TERM=dumb ^& %~n0 demo %demo_type%
203203
)
@@ -290,12 +290,15 @@ if "%~1"=="--help" (
290290
)
291291
)
292292
)
293-
) else if "%~1:~0,7%"=="--mask=" (
294-
:: Already processed for password demo
295-
rem Do nothing
296293
) else (
297-
:: Unknown option, assume it's a JVM option
298-
set "JVM_OPTS=!JVM_OPTS! %~1"
294+
set "arg=%~1"
295+
if "!arg:~0,7!"=="--mask=" (
296+
:: Already processed for password demo
297+
rem Do nothing
298+
) else (
299+
:: Unknown option, assume it's a JVM option
300+
set "JVM_OPTS=!JVM_OPTS! %~1"
301+
)
299302
)
300303

301304
shift
@@ -313,14 +316,16 @@ set "java_version=%java_version:~0,2%"
313316
set "java_version=%java_version:~0,2%"
314317
if "%java_version:~1,1%"=="." set "java_version=%java_version:~0,1%"
315318

316-
:: Add --enable-native-access if JDK 16+
317-
if %java_version% GEQ 16 (
318-
:: Only add if not already present
319-
echo %JVM_OPTS% | findstr /C:"--enable-native-access=ALL-UNNAMED" >nul
320-
if errorlevel 1 (
321-
set "JVM_OPTS=%JVM_OPTS% --enable-native-access=ALL-UNNAMED"
322-
)
323-
)
319+
:: Check Java version for --enable-native-access
320+
for /f "tokens=3" %%v in ('java -version 2^>^&1 ^| findstr /i "version"') do set "java_version=%%v"
321+
set "java_version=%java_version:"=%"
322+
set "java_version=%java_version:~0,2%"
323+
if "%java_version:~1,1%"=="." set "java_version=%java_version:~0,1%"
324+
:: Default to JDK 8 behavior if version not detected
325+
if not defined java_version set "java_version=8"
326+
:: Add --enable-native-access only for Java 16+
327+
echo %java_version% | findstr /C:"16" /C:"17" /C:"18" /C:"19" /C:"20" /C:"21" /C:"22" >nul
328+
if not errorlevel 1 set "JVM_OPTS=%JVM_OPTS% --enable-native-access=ALL-UNNAMED"
324329

325330
:: Launch the demo
326331
echo Launching %MAIN_CLASS%...
@@ -404,7 +409,20 @@ java -cp "%cp%" %JVM_OPTS% org.jline.demo.examples.%example_name%
404409
goto :eof
405410

406411
:rebuild
407-
call mvnw.cmd clean install %*
412+
:: Check if the first argument is "rebuild" and remove it if so
413+
set "mvn_args="
414+
:parse_rebuild_args
415+
if "%~1"=="" goto :do_rebuild
416+
if "%~1"=="rebuild" (
417+
shift
418+
goto :parse_rebuild_args
419+
)
420+
set "mvn_args=%mvn_args% %~1"
421+
shift
422+
goto :parse_rebuild_args
423+
424+
:do_rebuild
425+
call mvnw.cmd clean install%mvn_args%
408426
goto :eof
409427

410428
:license_check

0 commit comments

Comments
 (0)