changeset 10775:e2e750c9aa4a

8194144: com.oracle.tools.packager.Bundler.execute() returns null on MAC Reviewed-by: kcr
author vdrozdov
date Mon, 08 Jan 2018 22:08:58 -0800
parents 3df4a332d987
children b43e44ecc365
files modules/jdk.packager/src/main/java/com/oracle/tools/packager/IOUtils.java modules/jdk.packager/src/main/java/jdk/packager/internal/legacy/builders/AbstractAppImageBuilder.java modules/jdk.packager/src/main/java/jdk/packager/internal/legacy/builders/linux/LinuxAppImageBuilder.java modules/jdk.packager/src/main/java/jdk/packager/internal/legacy/builders/mac/MacAppImageBuilder.java modules/jdk.packager/src/main/java/jdk/packager/internal/legacy/builders/windows/WindowsAppImageBuilder.java
diffstat 5 files changed, 33 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/modules/jdk.packager/src/main/java/com/oracle/tools/packager/IOUtils.java	Tue Jan 09 09:46:48 2018 +0530
+++ b/modules/jdk.packager/src/main/java/com/oracle/tools/packager/IOUtils.java	Mon Jan 08 22:08:58 2018 -0800
@@ -77,6 +77,24 @@
         });
     }
 
+    public static void copyRecursive(Path src, Path dest) throws IOException {
+        Files.walkFileTree(src, new SimpleFileVisitor<Path>() {
+            @Override
+            public FileVisitResult preVisitDirectory(final Path dir,
+                    final BasicFileAttributes attrs) throws IOException {
+                Files.createDirectories(dest.resolve(src.relativize(dir)));
+                return FileVisitResult.CONTINUE;
+            }
+
+            @Override
+            public FileVisitResult visitFile(final Path file,
+                    final BasicFileAttributes attrs) throws IOException {
+                Files.copy(file, dest.resolve(src.relativize(file)));
+                return FileVisitResult.CONTINUE;
+            }
+        });
+    }
+
     public static void copyFromURL(URL location, File file) throws IOException {
         copyFromURL(location, file, false);
     }
--- a/modules/jdk.packager/src/main/java/jdk/packager/internal/legacy/builders/AbstractAppImageBuilder.java	Tue Jan 09 09:46:48 2018 +0530
+++ b/modules/jdk.packager/src/main/java/jdk/packager/internal/legacy/builders/AbstractAppImageBuilder.java	Mon Jan 08 22:08:58 2018 -0800
@@ -26,6 +26,7 @@
 package jdk.packager.internal.legacy.builders;
 
 
+import com.oracle.tools.packager.IOUtils;
 import com.oracle.tools.packager.RelativeFileSet;
 
 import com.oracle.tools.packager.Log;
@@ -99,6 +100,17 @@
         return result;
     }
 
+    protected void copyEntry(Path appDir, File srcdir, String fname) throws IOException {
+        Path dest = appDir.resolve(fname);
+        Files.createDirectories(dest.getParent());
+        File src = new File(srcdir, fname);
+        if (src.isDirectory()) {
+            IOUtils.copyRecursive(src.toPath(), dest);
+        } else {
+            Files.copy(src.toPath(), dest);
+        }
+    }
+
     protected InputStream locateResource(String publicName, String category,
                                          String defaultName, File customFile,
                                          boolean verbose, File publicRoot) throws IOException {
--- a/modules/jdk.packager/src/main/java/jdk/packager/internal/legacy/builders/linux/LinuxAppImageBuilder.java	Tue Jan 09 09:46:48 2018 +0530
+++ b/modules/jdk.packager/src/main/java/jdk/packager/internal/legacy/builders/linux/LinuxAppImageBuilder.java	Mon Jan 08 22:08:58 2018 -0800
@@ -227,10 +227,7 @@
             }
             File srcdir = appResources.getBaseDirectory();
             for (String fname : appResources.getIncludedFiles()) {
-                writeEntry(
-                        new FileInputStream(new File(srcdir, fname)),
-                        new File(appDir.toFile(), fname).toPath()
-                );
+                copyEntry(appDir, srcdir, fname);
             }
         }
     }
--- a/modules/jdk.packager/src/main/java/jdk/packager/internal/legacy/builders/mac/MacAppImageBuilder.java	Tue Jan 09 09:46:48 2018 +0530
+++ b/modules/jdk.packager/src/main/java/jdk/packager/internal/legacy/builders/mac/MacAppImageBuilder.java	Mon Jan 08 22:08:58 2018 -0800
@@ -444,9 +444,7 @@
         for (RelativeFileSet classPath : resourcesList) {
             File srcdir = classPath.getBaseDirectory();
             for (String fname : classPath.getIncludedFiles()) {
-                // use new File since fname can have file separators
-                writeEntry(new FileInputStream(new File(srcdir, fname)),
-                           new File(javaDirectory.toFile(), fname).toPath());
+                copyEntry(javaDirectory, srcdir, fname);
             }
         }
     }
--- a/modules/jdk.packager/src/main/java/jdk/packager/internal/legacy/builders/windows/WindowsAppImageBuilder.java	Tue Jan 09 09:46:48 2018 +0530
+++ b/modules/jdk.packager/src/main/java/jdk/packager/internal/legacy/builders/windows/WindowsAppImageBuilder.java	Mon Jan 08 22:08:58 2018 -0800
@@ -435,8 +435,7 @@
             }
             File srcdir = appResources.getBaseDirectory();
             for (String fname : appResources.getIncludedFiles()) {
-                writeEntry(new FileInputStream(new File(srcdir, fname)),
-                           new File(appDir.toFile(), fname).toPath());
+                copyEntry(appDir, srcdir, fname);
             }
         }
     }