|
| 1 | +@echo off |
| 2 | +REM VRL distribution script (creates app bundles and installers). |
| 3 | +REM (c) 2020 by Michael Hoffer <info@michaelhoffer.de> |
| 4 | +REM This script can easily be adapted for other applications as well. |
| 5 | + |
| 6 | +REM App distribution configuration: |
| 7 | +REM - specify app name, jar file and desired app type (msi, app-bundle, etc.) |
| 8 | +REM - since jpackage is still in preview, we download a recent JDK installation that |
| 9 | +REM is used locally to build the application package |
| 10 | +SET APP_NAME="SpaceFX" |
| 11 | +SET APP_JAR="SpaceFX-1.0-SNAPSHOT.jar" |
| 12 | +SET APP_TYPE="msi" |
| 13 | +SET JPACKAGE_JVM="https://download.java.net/java/GA/jdk14/076bab302c7b4508975440c56f6cc26a/36/GPL/openjdk-14_windows-x64_bin.zip" |
| 14 | +REM App version is passed as argument by github action workflow |
| 15 | +SET APP_VERSION=%1 |
| 16 | + |
| 17 | +REM Please don't change the rest of the script. If something doesn't work |
| 18 | +REM then create an issue where we can discuss potential changes. |
| 19 | +set DIR="%~dp0" |
| 20 | +echo Building distribution in dir: %DIR% |
| 21 | +cd %DIR% |
| 22 | + |
| 23 | +REM Check for 7zip and curl which are used to download and unpack the local Java distribution. |
| 24 | +for %%X in (7z.exe) do (set FOUND7Z=%%~$PATH:X) |
| 25 | +for %%X in (curl.exe) do (set FOUNDCURL=%%~$PATH:X) |
| 26 | +if not defined FOUND7Z ( |
| 27 | + echo "ERROR: please make sure that 7Zip is installed and on the path." |
| 28 | +) |
| 29 | +if not defined FOUNDCURL ( |
| 30 | + echo "ERROR: please make sure that Curl is installed and on the path." |
| 31 | +) |
| 32 | + |
| 33 | +REM Do not create the local JDK if it already exists |
| 34 | +if exist ".tmp-runtime\jdk-14\" ( |
| 35 | + echo "> jdk 14 for package generation already downloaded" |
| 36 | +) else ( |
| 37 | +REM If it doesn't exist, however, download and unpack the local JDK |
| 38 | +REM and create runtime image with the runtime JDK |
| 39 | +REM (JAVA_HOME is expected to be set correctly) |
| 40 | + mkdir .tmp-runtime\ |
| 41 | + cd .tmp-runtime |
| 42 | + echo "> downloading jdk 14" |
| 43 | + curl -o jdk14.zip %JPACKAGE_JVM% |
| 44 | + echo "> unpacking jdk 14" |
| 45 | + 7z x jdk14.zip |
| 46 | + echo "> creating runtime image" |
| 47 | + "%JAVA_HOME%\bin\jlink" -p "%JAVA_HOME%\jmods" ^ |
| 48 | + --add-modules java.desktop ^ |
| 49 | + --strip-debug ^ |
| 50 | + --no-header-files ^ |
| 51 | + --no-man-pages ^ |
| 52 | + --strip-native-commands ^ |
| 53 | + --vm=server ^ |
| 54 | + --compress=2 ^ |
| 55 | + --output runtime |
| 56 | +) |
| 57 | + |
| 58 | +REM Change to distribution directory (script location) where |
| 59 | +REM we will create the final application package |
| 60 | +cd %DIR% |
| 61 | + |
| 62 | +REM Finally, invoke the jpackage CLI program from the local JDK that |
| 63 | +REM has been downloaded earlier. |
| 64 | +set JPKG_HOME=.tmp-runtime\jdk-14\ |
| 65 | +set JPKG_EXECUTABLE=%JPKG_HOME%\bin\jpackage |
| 66 | +%JPKG_EXECUTABLE% --input ..\..\build\libs\ ^ |
| 67 | + --name %APP_NAME% ^ |
| 68 | + --main-jar %APP_JAR% ^ |
| 69 | + --type %APP_TYPE% ^ |
| 70 | + --runtime-image .tmp-runtime\runtime ^ |
| 71 | + --app-version 0.0.0 ^ |
| 72 | + --win-per-user-install ^ |
| 73 | + --win-menu ^ |
| 74 | + --win-menu-group SpaceFX |
| 75 | + |
| 76 | +REM Rename the application MSI |
| 77 | +move SpaceFX-0.0.0.msi SpaceFX-%APP_VERSION%-windows-x64.msi |
| 78 | + |
| 79 | +REM Show final MSI package |
| 80 | +dir *.msi |
0 commit comments