-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreview.bat
More file actions
58 lines (52 loc) · 1.89 KB
/
Copy pathpreview.bat
File metadata and controls
58 lines (52 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
@echo off
setlocal
set "TOOL_ROOT=%~dp0."
call :find_jdk
if errorlevel 1 exit /b %ERRORLEVEL%
set "PREVIEW_LAUNCHER=%TOOL_ROOT%\bin\modularui2-preview.bat"
if not exist "%PREVIEW_LAUNCHER%" (
set "PREVIEW_LAUNCHER=%TOOL_ROOT%\build\install\modularui2-preview\bin\modularui2-preview.bat"
if not exist "%PREVIEW_LAUNCHER%" (
call "%TOOL_ROOT%\gradlew.bat" -p "%TOOL_ROOT%" installDist
if errorlevel 1 exit /b 1
)
)
call "%PREVIEW_LAUNCHER%" %*
exit /b %ERRORLEVEL%
:find_jdk
if defined JAVA_HOME (
set "PREVIEW_JAVA=%JAVA_HOME%\bin\java.exe"
set "PREVIEW_JAVAC=%JAVA_HOME%\bin\javac.exe"
) else (
where java.exe >nul 2>nul || (
echo ModularUI2 Preview requires JDK 25. Set JAVA_HOME or add java and javac to PATH. 1>&2
exit /b 2
)
where javac.exe >nul 2>nul || (
echo ModularUI2 Preview requires a JDK with javac, not a JRE. 1>&2
exit /b 2
)
set "PREVIEW_JAVA=java.exe"
set "PREVIEW_JAVAC=javac.exe"
)
if not exist "%PREVIEW_JAVA%" if not "%PREVIEW_JAVA%"=="java.exe" (
echo JAVA_HOME does not contain bin\java.exe: %JAVA_HOME% 1>&2
exit /b 2
)
if not exist "%PREVIEW_JAVAC%" if not "%PREVIEW_JAVAC%"=="javac.exe" (
echo JAVA_HOME does not contain bin\javac.exe: %JAVA_HOME% 1>&2
exit /b 2
)
set "PREVIEW_JAVA_VERSION="
for /f "tokens=1,2,3" %%A in ('"%PREVIEW_JAVA%" -version 2^>^&1') do if not defined PREVIEW_JAVA_VERSION (
if /i "%%B"=="version" set "PREVIEW_JAVA_VERSION=%%~C"
if /i "%%A"=="openjdk" if /i not "%%B"=="version" set "PREVIEW_JAVA_VERSION=%%~B"
)
for /f "tokens=1 delims=." %%V in ("%PREVIEW_JAVA_VERSION%") do set "PREVIEW_JAVA_MAJOR=%%V"
set "PREVIEW_JAVA_MAJOR_NUMBER=0"
set /a PREVIEW_JAVA_MAJOR_NUMBER=%PREVIEW_JAVA_MAJOR% >nul 2>nul
if %PREVIEW_JAVA_MAJOR_NUMBER% LSS 25 (
echo ModularUI2 Preview requires JDK 25 or newer; found %PREVIEW_JAVA_VERSION%. 1>&2
exit /b 2
)
exit /b 0