From 62edc06eb1bced90ddbc823bf4d5c92af89eedd7 Mon Sep 17 00:00:00 2001 From: Anton Keks Date: Sat, 26 Nov 2022 15:55:05 +0200 Subject: [PATCH] use jlink for macOS builds --- build.gradle | 12 +++++++----- .../Angry IP Scanner.app/Contents/MacOS/ipscan | 3 +-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 4bf683c0..790e307d 100644 --- a/build.gradle +++ b/build.gradle @@ -224,7 +224,9 @@ def macLauncher(def platform) { ant.fileset(dir: "ext/mac-bundle") } - ant.copy(file: "${dist}/${project.name}-${platform}-${version}.jar", todir: "${dist}/${name}.app/Contents/MacOS") + def target = "${dist}/${name}.app/Contents/MacOS" + ant.copy(file: "${dist}/${project.name}-${platform}-${version}.jar", todir: target) + jlink(target, "jre") ant.replace(file: "${dist}/${name}.app/Contents/Info.plist") { ant.replacefilter(token: "APPNAME", value: name) @@ -272,11 +274,11 @@ packageTask('macArm64') { macLauncher("macArm64") } -def jlink(String installerDir, String jrePath) { - def jreDir = new File(installerDir, jrePath) +def jlink(String target, String jrePath, String extraOpts = "") { + def jreDir = new File(target, jrePath) if (!jreDir.exists()) { jreDir.getParentFile().mkdirs() - exec("jlink --output $jrePath --vm=client --compress=2 --no-header-files --no-man-pages --strip-debug --add-modules " + javaModules.join(","), installerDir) + exec("jlink --output $jrePath $extraOpts --compress=2 --no-header-files --no-man-pages --strip-debug --add-modules " + javaModules.join(","), target) ant.delete(dir: new File(jreDir, "legal")) } } @@ -292,7 +294,7 @@ task 'win-installer'(dependsOn: 'win64') { ant.replacefilter(token: "VERSION_MINOR", value: "8") ant.replacefilter(token: "VERSION", value: version) } - jlink(installerDir, "AppFiles/jre") + jlink(installerDir, "AppFiles/jre", "--vm=client") ant.copy(file: "resources/images/icon.ico", todir: "${installerDir}/AppFiles") ant.copy(file: "LICENSE", tofile: "${installerDir}/AppFiles/license.txt") ant.copy(file: "build/libs/${project.name}-win64-${version}.exe", tofile:"${installerDir}/AppFiles/ipscan.exe") diff --git a/ext/mac-bundle/Angry IP Scanner.app/Contents/MacOS/ipscan b/ext/mac-bundle/Angry IP Scanner.app/Contents/MacOS/ipscan index b4b45fb7..31fb3741 100755 --- a/ext/mac-bundle/Angry IP Scanner.app/Contents/MacOS/ipscan +++ b/ext/mac-bundle/Angry IP Scanner.app/Contents/MacOS/ipscan @@ -1,4 +1,3 @@ #!/bin/sh BASEDIR=`dirname "$0"` -which java || osascript -e 'display notification "You need Java/OpenJDK 11 installed" with title "Angry IP Scanner"' -exec java --add-opens java.base/java.net=ALL-UNNAMED -XstartOnFirstThread -jar "$BASEDIR"/ipscan*.jar +exec "$BASEDIR/jre/bin/java" --add-opens java.base/java.net=ALL-UNNAMED -XstartOnFirstThread -jar "$BASEDIR"/ipscan*.jar