Skip to content

Commit

Permalink
use jlink for macOS builds
Browse files Browse the repository at this point in the history
  • Loading branch information
angryziber committed Nov 26, 2022
1 parent bc0ee11 commit 62edc06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 7 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"))
}
}
Expand All @@ -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")
Expand Down
3 changes: 1 addition & 2 deletions ext/mac-bundle/Angry IP Scanner.app/Contents/MacOS/ipscan
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 62edc06

Please sign in to comment.