Add build-jres.sh script for minimal JRE creation and update packr configs
- Creates minimal JREs (~50MB vs ~300MB) using jlink - Downloads Corretto JDKs for specified Java version - Supports linux-x64, windows-x64, macos-x64, macos-arm64 - Note: Windows ARM64 not available from Corretto - Updates all packr configs to use minimal JREs - Adds macOS ARM64 build configs
This commit is contained in:
241
desktop/build-jres.sh
Executable file
241
desktop/build-jres.sh
Executable file
@@ -0,0 +1,241 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
JAVA_VERSION="${1:-11}"
|
||||||
|
JVM_DIR="$(cd "$(dirname "$0")/jvms" && pwd)"
|
||||||
|
MODULES="java.base,java.desktop,java.logging,java.sql,java.xml,java.naming,java.management,jdk.unsupported"
|
||||||
|
|
||||||
|
CORRETTO_BASE_URL="https://corretto.aws/downloads/latest"
|
||||||
|
|
||||||
|
build_linux_x64() {
|
||||||
|
local platform="linux-x64"
|
||||||
|
local url="${CORRETTO_BASE_URL}/amazon-corretto-${JAVA_VERSION}-x64-linux-jdk.tar.gz"
|
||||||
|
local archive="${JVM_DIR}/corretto${JAVA_VERSION}-${platform}.tar.gz"
|
||||||
|
local extract_dir="${JVM_DIR}/tmp-${platform}"
|
||||||
|
local jre_dir="${JVM_DIR}/jre-${platform}"
|
||||||
|
|
||||||
|
echo "=== Building $platform ==="
|
||||||
|
|
||||||
|
echo "Downloading..."
|
||||||
|
curl -L -o "$archive" "$url"
|
||||||
|
|
||||||
|
echo "Extracting..."
|
||||||
|
rm -rf "$extract_dir" "$jre_dir"
|
||||||
|
mkdir -p "$extract_dir"
|
||||||
|
tar -xzf "$archive" -C "$extract_dir" --strip-components=1
|
||||||
|
|
||||||
|
echo "Creating minimal JRE..."
|
||||||
|
"$extract_dir/bin/jlink" \
|
||||||
|
--no-header-files \
|
||||||
|
--no-man-pages \
|
||||||
|
--compress=2 \
|
||||||
|
--add-modules "$MODULES" \
|
||||||
|
--output "$jre_dir"
|
||||||
|
|
||||||
|
rm -rf "$extract_dir"
|
||||||
|
|
||||||
|
echo "Done: $(du -sh "$jre_dir" | cut -f1)"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
build_windows_x64() {
|
||||||
|
local platform="windows-x64"
|
||||||
|
local url="${CORRETTO_BASE_URL}/amazon-corretto-${JAVA_VERSION}-x64-windows-jdk.zip"
|
||||||
|
local archive="${JVM_DIR}/corretto${JAVA_VERSION}-${platform}.zip"
|
||||||
|
local extract_dir="${JVM_DIR}/tmp-${platform}"
|
||||||
|
local jre_dir="${JVM_DIR}/jre-${platform}"
|
||||||
|
local host_jdk="${JVM_DIR}/tmp-linux-x64"
|
||||||
|
|
||||||
|
echo "=== Building $platform ==="
|
||||||
|
|
||||||
|
if [ ! -d "$host_jdk" ]; then
|
||||||
|
echo "Downloading host JDK for jlink..."
|
||||||
|
local host_archive="${JVM_DIR}/corretto${JAVA_VERSION}-linux-x64.tar.gz"
|
||||||
|
curl -L -o "$host_archive" "${CORRETTO_BASE_URL}/amazon-corretto-${JAVA_VERSION}-x64-linux-jdk.tar.gz"
|
||||||
|
mkdir -p "$host_jdk"
|
||||||
|
tar -xzf "$host_archive" -C "$host_jdk" --strip-components=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Downloading..."
|
||||||
|
curl -L -o "$archive" "$url"
|
||||||
|
|
||||||
|
echo "Extracting..."
|
||||||
|
rm -rf "$extract_dir" "$jre_dir"
|
||||||
|
mkdir -p "$extract_dir"
|
||||||
|
unzip -q "$archive" -d "$extract_dir"
|
||||||
|
|
||||||
|
local jdk_dir=$(find "$extract_dir" -maxdepth 1 -type d -name "jdk*" | head -1)
|
||||||
|
local jmods_path="$jdk_dir/jmods"
|
||||||
|
|
||||||
|
echo "Creating minimal JRE..."
|
||||||
|
"$host_jdk/bin/jlink" \
|
||||||
|
--no-header-files \
|
||||||
|
--no-man-pages \
|
||||||
|
--compress=2 \
|
||||||
|
--add-modules "$MODULES" \
|
||||||
|
--module-path "$jmods_path" \
|
||||||
|
--output "$jre_dir"
|
||||||
|
|
||||||
|
rm -rf "$extract_dir"
|
||||||
|
|
||||||
|
echo "Done: $(du -sh "$jre_dir" | cut -f1)"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
build_windows_arm64() {
|
||||||
|
echo "=== Building windows-arm64 ==="
|
||||||
|
echo "ERROR: Windows ARM64 JDK is not available from Amazon Corretto"
|
||||||
|
echo "Skipping..."
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
build_macos_x64() {
|
||||||
|
local platform="macos-x64"
|
||||||
|
local url="${CORRETTO_BASE_URL}/amazon-corretto-${JAVA_VERSION}-x64-macos-jdk.tar.gz"
|
||||||
|
local archive="${JVM_DIR}/corretto${JAVA_VERSION}-${platform}.tar.gz"
|
||||||
|
local extract_dir="${JVM_DIR}/tmp-${platform}"
|
||||||
|
local jre_dir="${JVM_DIR}/jre-${platform}"
|
||||||
|
local host_jdk="${JVM_DIR}/tmp-linux-x64"
|
||||||
|
|
||||||
|
echo "=== Building $platform ==="
|
||||||
|
|
||||||
|
if [ ! -d "$host_jdk" ]; then
|
||||||
|
echo "Downloading host JDK for jlink..."
|
||||||
|
local host_archive="${JVM_DIR}/corretto${JAVA_VERSION}-linux-x64.tar.gz"
|
||||||
|
curl -L -o "$host_archive" "${CORRETTO_BASE_URL}/amazon-corretto-${JAVA_VERSION}-x64-linux-jdk.tar.gz"
|
||||||
|
mkdir -p "$host_jdk"
|
||||||
|
tar -xzf "$host_archive" -C "$host_jdk" --strip-components=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Downloading..."
|
||||||
|
curl -L -o "$archive" "$url"
|
||||||
|
|
||||||
|
echo "Extracting..."
|
||||||
|
rm -rf "$extract_dir" "$jre_dir"
|
||||||
|
mkdir -p "$extract_dir"
|
||||||
|
tar -xzf "$archive" -C "$extract_dir"
|
||||||
|
|
||||||
|
local jdk_dir=$(find "$extract_dir" -maxdepth 1 -type d -name "jdk*" -o -name "amazon-corretto*" | head -1)
|
||||||
|
local jmods_path="$jdk_dir/Contents/Home/jmods"
|
||||||
|
|
||||||
|
if [ ! -d "$jmods_path" ]; then
|
||||||
|
jmods_path="$jdk_dir/jmods"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Creating minimal JRE..."
|
||||||
|
"$host_jdk/bin/jlink" \
|
||||||
|
--no-header-files \
|
||||||
|
--no-man-pages \
|
||||||
|
--compress=2 \
|
||||||
|
--add-modules "$MODULES" \
|
||||||
|
--module-path "$jmods_path" \
|
||||||
|
--output "$jre_dir"
|
||||||
|
|
||||||
|
rm -rf "$extract_dir"
|
||||||
|
|
||||||
|
echo "Done: $(du -sh "$jre_dir" | cut -f1)"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
build_macos_arm64() {
|
||||||
|
local platform="macos-arm64"
|
||||||
|
local url="${CORRETTO_BASE_URL}/amazon-corretto-${JAVA_VERSION}-aarch64-macos-jdk.tar.gz"
|
||||||
|
local archive="${JVM_DIR}/corretto${JAVA_VERSION}-${platform}.tar.gz"
|
||||||
|
local extract_dir="${JVM_DIR}/tmp-${platform}"
|
||||||
|
local jre_dir="${JVM_DIR}/jre-${platform}"
|
||||||
|
local host_jdk="${JVM_DIR}/tmp-linux-x64"
|
||||||
|
|
||||||
|
echo "=== Building $platform ==="
|
||||||
|
|
||||||
|
if [ ! -d "$host_jdk" ]; then
|
||||||
|
echo "Downloading host JDK for jlink..."
|
||||||
|
local host_archive="${JVM_DIR}/corretto${JAVA_VERSION}-linux-x64.tar.gz"
|
||||||
|
curl -L -o "$host_archive" "${CORRETTO_BASE_URL}/amazon-corretto-${JAVA_VERSION}-x64-linux-jdk.tar.gz"
|
||||||
|
mkdir -p "$host_jdk"
|
||||||
|
tar -xzf "$host_archive" -C "$host_jdk" --strip-components=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Downloading..."
|
||||||
|
curl -L -o "$archive" "$url"
|
||||||
|
|
||||||
|
echo "Extracting..."
|
||||||
|
rm -rf "$extract_dir" "$jre_dir"
|
||||||
|
mkdir -p "$extract_dir"
|
||||||
|
tar -xzf "$archive" -C "$extract_dir"
|
||||||
|
|
||||||
|
local jdk_dir=$(find "$extract_dir" -maxdepth 1 -type d -name "jdk*" -o -name "amazon-corretto*" | head -1)
|
||||||
|
local jmods_path="$jdk_dir/Contents/Home/jmods"
|
||||||
|
|
||||||
|
if [ ! -d "$jmods_path" ]; then
|
||||||
|
jmods_path="$jdk_dir/jmods"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Creating minimal JRE..."
|
||||||
|
"$host_jdk/bin/jlink" \
|
||||||
|
--no-header-files \
|
||||||
|
--no-man-pages \
|
||||||
|
--compress=2 \
|
||||||
|
--add-modules "$MODULES" \
|
||||||
|
--module-path "$jmods_path" \
|
||||||
|
--output "$jre_dir"
|
||||||
|
|
||||||
|
rm -rf "$extract_dir"
|
||||||
|
|
||||||
|
echo "Done: $(du -sh "$jre_dir" | cut -f1)"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
mkdir -p "$JVM_DIR"
|
||||||
|
|
||||||
|
local target="${2:-all}"
|
||||||
|
|
||||||
|
echo "Building JREs for Java $JAVA_VERSION"
|
||||||
|
echo "Modules: $MODULES"
|
||||||
|
echo "Target: $target"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
case "$target" in
|
||||||
|
linux-x64)
|
||||||
|
build_linux_x64
|
||||||
|
;;
|
||||||
|
windows-x64)
|
||||||
|
build_windows_x64
|
||||||
|
;;
|
||||||
|
windows-arm64)
|
||||||
|
build_windows_arm64
|
||||||
|
;;
|
||||||
|
macos-x64)
|
||||||
|
build_macos_x64
|
||||||
|
;;
|
||||||
|
macos-arm64)
|
||||||
|
build_macos_arm64
|
||||||
|
;;
|
||||||
|
all)
|
||||||
|
build_linux_x64
|
||||||
|
build_windows_x64
|
||||||
|
build_macos_x64
|
||||||
|
build_macos_arm64
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown target: $target"
|
||||||
|
echo "Valid targets: linux-x64, windows-x64, macos-x64, macos-arm64, all"
|
||||||
|
echo "Note: windows-arm64 is not available from Corretto"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "=== Summary ==="
|
||||||
|
for platform in linux-x64 windows-x64 macos-x64 macos-arm64; do
|
||||||
|
local jre_dir="${JVM_DIR}/jre-${platform}"
|
||||||
|
if [ -d "$jre_dir" ]; then
|
||||||
|
local size=$(du -sh "$jre_dir" | cut -f1)
|
||||||
|
echo "$platform: $size"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -rf "${JVM_DIR}/tmp-linux-x64"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
{
|
{
|
||||||
"platform": "linux64",
|
"platform": "linux64",
|
||||||
"vmargs": ["-Duse-repl=false", "-Dui_scale=1.0", "-Dclojure.compiler.direct-linking=true", "-Dis-desktop=true", "-Dplatform=desktop"],
|
"vmargs": ["-Duse-repl=false", "-Dui_scale=1.0", "-Dclojure.compiler.direct-linking=true", "-Dis-desktop=true", "-Dplatform=desktop"],
|
||||||
"jdk": "./jvms/corretto11-linux.tar.gz",
|
"jdk": "./jvms/jre-linux-x64",
|
||||||
"executable": "Tick's Tales",
|
"executable": "Tick's Tales",
|
||||||
"classpath": ["target/advent-standalone.jar"],
|
"classpath": ["target/advent-standalone.jar"],
|
||||||
"mainclass": "advent.core.desktop_launcher",
|
"mainclass": "advent.core.desktop_launcher",
|
||||||
"resources": ["steam_appid.txt", "resources/icon"],
|
"resources": ["steam_appid.txt", "resources/icon"],
|
||||||
"minimizejre": "soft",
|
|
||||||
"output": "target/linux/amd64"
|
"output": "target/linux/amd64"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
{
|
{
|
||||||
"platform": "linux64",
|
"platform": "linux64",
|
||||||
"vmargs": ["-Duse-repl=false", "-Dui_scale=1.0", "-Dno-steam=true", "-Dclojure.compiler.direct-linking=true", "-Dis-desktop=true", "-Dplatform=desktop"],
|
"vmargs": ["-Duse-repl=false", "-Dui_scale=1.0", "-Dno-steam=true", "-Dclojure.compiler.direct-linking=true", "-Dis-desktop=true", "-Dplatform=desktop"],
|
||||||
"jdk": "./jvms/corretto11-linux.tar.gz",
|
"jdk": "./jvms/jre-linux-x64",
|
||||||
"executable": "Tick's Tales",
|
"executable": "Tick's Tales",
|
||||||
"classpath": ["target/advent-standalone.jar"],
|
"classpath": ["target/advent-standalone.jar"],
|
||||||
"mainclass": "advent.core.desktop_launcher",
|
"mainclass": "advent.core.desktop_launcher",
|
||||||
"resources": ["steam_appid.txt", "resources/icon"],
|
"resources": ["steam_appid.txt", "resources/icon"],
|
||||||
"minimizejre": "soft",
|
|
||||||
"output": "target/linux/amd64"
|
"output": "target/linux/amd64"
|
||||||
}
|
}
|
||||||
|
|||||||
12
desktop/build-osx-arm64-steam.json
Normal file
12
desktop/build-osx-arm64-steam.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"platform": "mac",
|
||||||
|
"jdk": "./jvms/jre-macos-arm64",
|
||||||
|
"executable": "Tick's Tales",
|
||||||
|
"vmargs": ["-Duse-repl=false", "-Dui_scale=1.0", "-Dclojure.compiler.direct-linking=true", "-Dis-desktop=true", "-Dplatform=desktop", "-XstartOnFirstThread"],
|
||||||
|
"classpath": ["target/advent-standalone.jar"],
|
||||||
|
"mainclass": "advent.core.desktop_launcher",
|
||||||
|
"resources": ["resources/icon", "steam_appid.txt"],
|
||||||
|
"output": "target/osx-arm64/Tick's Tales.app",
|
||||||
|
"bundle": "com.tickstales.upallknight",
|
||||||
|
"verbose": true
|
||||||
|
}
|
||||||
12
desktop/build-osx-arm64.json
Normal file
12
desktop/build-osx-arm64.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"platform": "mac",
|
||||||
|
"jdk": "./jvms/jre-macos-arm64",
|
||||||
|
"executable": "Tick's Tales",
|
||||||
|
"vmargs": ["-Duse-repl=false", "-Dui_scale=1.0", "-Dno-steam=true", "-Dclojure.compiler.direct-linking=true", "-Dis-desktop=true", "-Dplatform=desktop", "-XstartOnFirstThread"],
|
||||||
|
"classpath": ["target/advent-standalone.jar"],
|
||||||
|
"mainclass": "advent.core.desktop_launcher",
|
||||||
|
"resources": ["resources/icon", "steam_appid.txt"],
|
||||||
|
"output": "target/osx-arm64/Tick's Tales.app",
|
||||||
|
"bundle": "com.tickstales.upallknight",
|
||||||
|
"verbose": true
|
||||||
|
}
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
{
|
{
|
||||||
"platform": "mac",
|
"platform": "mac",
|
||||||
"jdk": "./jvms/corretto11-macos.tar.gz",
|
"jdk": "./jvms/jre-macos-x64",
|
||||||
"executable": "Tick's Tales",
|
"executable": "Tick's Tales",
|
||||||
"vmargs": ["-Duse-repl=false", "-Dui_scale=1.0", "-Dclojure.compiler.direct-linking=true", "-Dis-desktop=true", "-Dplatform=desktop", "-XstartOnFirstThread"],
|
"vmargs": ["-Duse-repl=false", "-Dui_scale=1.0", "-Dclojure.compiler.direct-linking=true", "-Dis-desktop=true", "-Dplatform=desktop", "-XstartOnFirstThread"],
|
||||||
"classpath": ["target/advent-standalone.jar"],
|
"classpath": ["target/advent-standalone.jar"],
|
||||||
"mainclass": "advent.core.desktop_launcher",
|
"mainclass": "advent.core.desktop_launcher",
|
||||||
"resources": ["resources/icon", "steam_appid.txt"],
|
"resources": ["resources/icon", "steam_appid.txt"],
|
||||||
"minimizejre": "soft",
|
|
||||||
"output": "target/osx/Tick's Tales.app",
|
"output": "target/osx/Tick's Tales.app",
|
||||||
"bundle": "com.tickstales.upallknight",
|
"bundle": "com.tickstales.upallknight",
|
||||||
"verbose": true
|
"verbose": true
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
{
|
{
|
||||||
"platform": "mac",
|
"platform": "mac",
|
||||||
"jdk": "./jvms/corretto11-macos.tar.gz",
|
"jdk": "./jvms/jre-macos-x64",
|
||||||
"executable": "Tick's Tales",
|
"executable": "Tick's Tales",
|
||||||
"vmargs": ["-Duse-repl=false", "-Dui_scale=1.0", "-Dno-steam=true", "-Dclojure.compiler.direct-linking=true", "-Dis-desktop=true", "-Dplatform=desktop", "-XstartOnFirstThread"],
|
"vmargs": ["-Duse-repl=false", "-Dui_scale=1.0", "-Dno-steam=true", "-Dclojure.compiler.direct-linking=true", "-Dis-desktop=true", "-Dplatform=desktop", "-XstartOnFirstThread"],
|
||||||
"classpath": ["target/advent-standalone.jar"],
|
"classpath": ["target/advent-standalone.jar"],
|
||||||
"mainclass": "advent.core.desktop_launcher",
|
"mainclass": "advent.core.desktop_launcher",
|
||||||
"resources": ["resources/icon", "steam_appid.txt"],
|
"resources": ["resources/icon", "steam_appid.txt"],
|
||||||
"minimizejre": "soft",
|
|
||||||
"output": "target/osx/Tick's Tales.app",
|
"output": "target/osx/Tick's Tales.app",
|
||||||
"bundle": "com.tickstales.upallknight",
|
"bundle": "com.tickstales.upallknight",
|
||||||
"verbose": true
|
"verbose": true
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
{
|
{
|
||||||
"platform": "windows64",
|
"platform": "windows64",
|
||||||
"vmargs": ["-Duse-repl=false", "-Dui_scale=1.0", "-Dclojure.compiler.direct-linking=true", "-Dis-desktop=true", "-Dplatform=desktop"],
|
"vmargs": ["-Duse-repl=false", "-Dui_scale=1.0", "-Dclojure.compiler.direct-linking=true", "-Dis-desktop=true", "-Dplatform=desktop"],
|
||||||
"jdk": "./jvms/corretto11-windows.zip",
|
"jdk": "./jvms/jre-windows-x64",
|
||||||
"executable": "TicksTales",
|
"executable": "TicksTales",
|
||||||
"mainclass": "advent.core.desktop_launcher",
|
"mainclass": "advent.core.desktop_launcher",
|
||||||
"resources": ["steam_appid.txt", "resources/icon"],
|
"resources": ["steam_appid.txt", "resources/icon"],
|
||||||
"classpath": ["target/advent-standalone.jar"],
|
"classpath": ["target/advent-standalone.jar"],
|
||||||
"minimizejre": "soft",
|
|
||||||
"output": "target/windows/"
|
"output": "target/windows/"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
{
|
{
|
||||||
"platform": "windows64",
|
"platform": "windows64",
|
||||||
"vmargs": ["-Duse-repl=false", "-Dui_scale=1.0", "-Dno-steam=true", "-Dclojure.compiler.direct-linking=true", "-Dis-desktop=true", "-Dplatform=desktop"],
|
"vmargs": ["-Duse-repl=false", "-Dui_scale=1.0", "-Dno-steam=true", "-Dclojure.compiler.direct-linking=true", "-Dis-desktop=true", "-Dplatform=desktop"],
|
||||||
"jdk": "./jvms/corretto11-windows.zip",
|
"jdk": "./jvms/jre-windows-x64",
|
||||||
"executable": "TicksTales",
|
"executable": "TicksTales",
|
||||||
"mainclass": "advent.core.desktop_launcher",
|
"mainclass": "advent.core.desktop_launcher",
|
||||||
"resources": ["steam_appid.txt", "resources/icon"],
|
"resources": ["steam_appid.txt", "resources/icon"],
|
||||||
"classpath": ["target/advent-standalone.jar"],
|
"classpath": ["target/advent-standalone.jar"],
|
||||||
"minimizejre": "soft",
|
|
||||||
"output": "target/windows/"
|
"output": "target/windows/"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user