diff --git a/README.md b/README.md index 3c13bfcde..c19d7d6bc 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,16 @@ tag. These directions are for the latest source, which may have experimental cod are incompatible with the current data files. These build instructions may have also changed since a given release, so be sure to review them again with the version you plan to build.* -1. Make sure you have JDK 14 (JDK 15 for macOS) installed and set to be used as your default Java - compiler. You can download it for your platform here: http://jdk.java.net/14/ - (http://jdk.java.net/15/ for macOS) +1. Make sure you have JDK 14 installed and set to be used as your default Java compiler. You can + download it for your platform here: http://jdk.java.net/14/ -2. If you are building on Windows, you'll need to install the WiX Toolset from here: +2. If you are building on macOS, you will also need to download and extract a copy of JDK 15 into + `~/jdk-15.jdk`. You can download it from here: http://jdk.java.net/15/ + +3. If you are building on Windows, you'll need to install the WiX Toolset from here: https://github.com/wixtoolset/wix3/releases/tag/wix3112rtm -3. Clone the source repositories: +4. Clone the source repositories: ``` % git clone https://github.com/richardwilkes/gcs ``` @@ -28,7 +30,7 @@ a given release, so be sure to review them again with the version you plan to bu % git clone https://github.com/richardwilkes/gcs_library ``` -4. Build and bundle the code for your platform: +5. Build and bundle the code for your platform: macOS and Linux: ``` diff --git a/bundler/bundler/Bundler.java b/bundler/bundler/Bundler.java index e4c26f5af..1633d2487 100644 --- a/bundler/bundler/Bundler.java +++ b/bundler/bundler/Bundler.java @@ -60,6 +60,7 @@ public class Bundler { private static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; private static String OS; private static Path PKG; + private static Path JPACKAGE_15; private static String ICON_TYPE; /** @@ -69,11 +70,6 @@ public class Bundler { */ public static void main(String[] args) { checkPlatform(); - if (MACOS.equals(OS)) { - // We only want JDK 15 for its updated jpackage tool, which otherwise is incapable of - // signing a macOS application. - JDK_MAJOR_VERSION = "15"; - } boolean sign = false; boolean notarize = false; @@ -142,7 +138,7 @@ private static void checkPlatform() { } private static void checkJDK() { - ProcessBuilder builder = new ProcessBuilder("javac", "-version"); + ProcessBuilder builder = new ProcessBuilder("javac", "--version"); builder.redirectOutput(Redirect.PIPE).redirectErrorStream(true); try { String versionLine = ""; @@ -164,6 +160,37 @@ private static void checkJDK() { System.err.println("JDK " + JDK_MAJOR_VERSION + " is not installed!"); emitInstallJDKMessageAndExit(); } + + if (OS.equals(MACOS)) { + boolean failed = false; + Path dir = Paths.get(System.getProperty("user.home", "."), "jdk-15.jdk").toAbsolutePath(); + JPACKAGE_15 = dir.resolve(Paths.get("Contents", "Home", "bin", "jpackage")); + builder = new ProcessBuilder(JPACKAGE_15.toString(), "--version"); + builder.redirectOutput(Redirect.PIPE).redirectErrorStream(true); + try { + String versionLine = ""; + Process process = builder.start(); + try (BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8))) { + String prefix = "15"; + String line; + while ((line = in.readLine()) != null) { + if (line.startsWith(prefix)) { + versionLine = line; + } + } + } + if (!versionLine.startsWith("15")) { + failed = true; + } + } catch (IOException exception) { + failed = true; + } + if (failed) { + System.err.println("jpackage 15 is not available!"); + System.err.println("Unpack JDK 15 from http://jdk.java.net/15/ into " + " and try again."); + System.exit(1); + } + } } private static void emitInstallJDKMessageAndExit() { @@ -565,7 +592,11 @@ private static void packageApp(boolean sign) { args.add("com.trollworks.gcs"); runNoOutputCmd("jlink", "--module-path", MODULE_DIR.toString(), "--output", JRE.toString(), "--compress=2", "--no-header-files", "--no-man-pages", "--strip-debug", "--strip-native-commands", "--add-modules", "com.trollworks.gcs"); args.clear(); - args.add("jpackage"); + if (OS.equals(MACOS)) { + args.add(JPACKAGE_15.toString()); + } else { + args.add("jpackage"); + } args.add("--module"); args.add("com.trollworks.gcs/com.trollworks.gcs.GCS"); args.add("--app-version");