From 983d962a64346118e626eb86b4c7011ce0c78137 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sun, 21 Apr 2019 08:30:47 -0400 Subject: [PATCH] update AppBundler, use newer macOS SDK, preserve attributes where possible --- build/macosx/appbundler/build.xml | 13 +++++++------ .../src/com/oracle/appbundler/AppBundlerTask.java | 13 +++++++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/build/macosx/appbundler/build.xml b/build/macosx/appbundler/build.xml index 9b48b2bb5..4d0220417 100644 --- a/build/macosx/appbundler/build.xml +++ b/build/macosx/appbundler/build.xml @@ -33,8 +33,8 @@ questions. version=1.0ea --> - - + + @@ -73,7 +73,8 @@ questions. - + + @@ -87,10 +88,10 @@ questions. - - + + diff --git a/build/macosx/appbundler/src/com/oracle/appbundler/AppBundlerTask.java b/build/macosx/appbundler/src/com/oracle/appbundler/AppBundlerTask.java index 8009c78b2..df4c26bc7 100644 --- a/build/macosx/appbundler/src/com/oracle/appbundler/AppBundlerTask.java +++ b/build/macosx/appbundler/src/com/oracle/appbundler/AppBundlerTask.java @@ -458,6 +458,7 @@ public class AppBundlerTask extends Task { } finally { outputStream.close(); } + file.setLastModified(zipEntry.getTime()); } zipEntry = zipInputStream.getNextEntry(); } @@ -729,7 +730,9 @@ public class AppBundlerTask extends Task { private static void copy(URL location, File file) throws IOException { try (InputStream in = location.openStream()) { - Files.copy(in, file.toPath(), StandardCopyOption.REPLACE_EXISTING); + Files.copy(in, file.toPath(), + // can't do attributes when coming from URL + StandardCopyOption.REPLACE_EXISTING); } } @@ -740,13 +743,15 @@ public class AppBundlerTask extends Task { destination.getParentFile().mkdirs(); - Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING, LinkOption.NOFOLLOW_LINKS); + Files.copy(sourcePath, destinationPath, + StandardCopyOption.REPLACE_EXISTING, + StandardCopyOption.COPY_ATTRIBUTES, + LinkOption.NOFOLLOW_LINKS); if (Files.isDirectory(sourcePath, LinkOption.NOFOLLOW_LINKS)) { String[] files = source.list(); - for (int i = 0; i < files.length; i++) { - String file = files[i]; + for (String file : files) { copy(new File(source, file), new File(destination, file)); } }