-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage-win.sh
More file actions
executable file
·61 lines (47 loc) · 1.5 KB
/
package-win.sh
File metadata and controls
executable file
·61 lines (47 loc) · 1.5 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
59
60
61
#!/bin/sh
set -e
# Configuration
PACKAGE_NAME="JavaAppTemplate-windows"
JRE_DIR="jre-windows"
ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/25/ga"
# Clean up any previous builds
rm -rf ${PACKAGE_NAME}
rm -rf ${JRE_DIR}
rm -f ${PACKAGE_NAME}.zip
# Build the application using Gradle
echo "Building application..."
./gradlew build
# Download JRE for Windows from Eclipse Adoptium
echo "Downloading JRE for Windows..."
mkdir -p ${JRE_DIR}
curl -L "${ADOPTIUM_BASE_URL}/windows/x64/jre/hotspot/normal/eclipse?project=jdk" -o ${JRE_DIR}/jre-windows.zip
# Extract the downloaded JRE
echo "Extracting JRE..."
cd ${JRE_DIR}
unzip -q jre-windows.zip
JRE_EXTRACTED=$(ls -d jdk* 2>/dev/null || ls -d jre* 2>/dev/null)
cd ..
# Create package directory structure
echo "Creating package structure..."
mkdir -p ${PACKAGE_NAME}
cp app/build/libs/app-all.jar ${PACKAGE_NAME}/app.jar
cp README.md ${PACKAGE_NAME}/README.txt
cp LICENSE ${PACKAGE_NAME}/LICENSE
# Copy the JRE into the package
echo "Copying JRE into package..."
cp -r ${JRE_DIR}/${JRE_EXTRACTED} ${PACKAGE_NAME}/jre
# Create a Windows batch file that uses the bundled JRE
cat > ${PACKAGE_NAME}/run.bat << 'EOF'
@echo off
jre\bin\java.exe -jar app.jar
@pause
EOF
# Create the final zip archive with maximum compression
echo "Creating zip archive..."
zip -9 -r ${PACKAGE_NAME}.zip ${PACKAGE_NAME}/
# Clean up temporary directories
rm -rf ${PACKAGE_NAME}
rm -rf ${JRE_DIR}
echo ""
echo "✓ Windows package with bundled JRE created: ${PACKAGE_NAME}.zip"
echo ""