diff --git a/scripts/create-mac-launcher.sh b/scripts/create-mac-launcher.sh new file mode 100644 index 00000000..c639dd6f --- /dev/null +++ b/scripts/create-mac-launcher.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# scripts/create-mac-launcher.sh + +# Create app structure +APP_NAME="Stirling-PDF" +APP_BUNDLE="$APP_NAME.app" +mkdir -p "$APP_BUNDLE/Contents/"{MacOS,Resources,Java} + +# Convert icon +sips -s format icns "src/main/resources/static/favicon.ico" --out "$APP_BUNDLE/Contents/Resources/AppIcon.icns" + +# Create Info.plist +cat > "$APP_BUNDLE/Contents/Info.plist" << EOF + + + + + CFBundleExecutable + $APP_NAME + CFBundleIconFile + AppIcon + CFBundleIdentifier + com.frooodle.stirlingpdf + CFBundleName + $APP_NAME + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + LSMinimumSystemVersion + 10.10.0 + LSEnvironment + + BROWSER_OPEN + true + + + +EOF + +# Create launcher script +cat > "$APP_BUNDLE/Contents/MacOS/$APP_NAME" << 'EOF' +#!/bin/bash + +# Configuration +MIN_JAVA_VERSION="17" +PREFERRED_JAVA_VERSION="21" +JAVA_DOWNLOAD_URL="https://download.oracle.com/java/21/latest/jdk-21_macos-x64_bin.dmg" + +# Check Java version +if type -p java > /dev/null; then + _java=java +elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then + _java="$JAVA_HOME/bin/java" +else + osascript -e 'display dialog "Java not found. Please install Java 21." buttons {"Download Java", "Cancel"} default button "Download Java"' \ + && open "$JAVA_DOWNLOAD_URL" + exit 1 +fi + +version=$("$_java" -version 2>&1 | awk -F '"' '/version/ {print $2}' | cut -d'.' -f1) +if [[ "$version" -lt "$MIN_JAVA_VERSION" ]]; then + osascript -e 'display dialog "Wrong Java version. Please install Java 21." buttons {"Download Java", "Cancel"} default button "Download Java"' \ + && open "$JAVA_DOWNLOAD_URL" + exit 1 +fi + +# Run application +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +exec java -jar "$DIR/../Java/Stirling-PDF.jar" "$@" +EOF + +chmod +x "$APP_BUNDLE/Contents/MacOS/$APP_NAME" + +# Copy JAR file +cp "build/libs/Stirling-PDF.jar" "$APP_BUNDLE/Contents/Java/"