changeset 9047:761213753af4

8138650: JavaFX WebView Native Library unacceptable to Mac App Store, filter it out when packaging reviewed-by: kcr, cbensen
author Danno Ferrin (shemnon) <danno.ferrin@oracle.com>
date Fri, 02 Oct 2015 15:33:14 -0600
parents 89d67373dbab
children 8e32fe9245af
files modules/fxpackager/src/main/java/com/oracle/tools/packager/AbstractImageBundler.java modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacAppStoreBundler.java modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacAppStoreBundlerTest.java
diffstat 3 files changed, 99 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/AbstractImageBundler.java	Fri Oct 02 18:39:46 2015 +0300
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/AbstractImageBundler.java	Fri Oct 02 15:33:14 2015 -0600
@@ -276,29 +276,45 @@
             params.put(".runtime.version.security", matcher.group(5));
             params.put(".runtime.version.patch", "0");
             params.put(".runtime.version.modifiers", matcher.group(7));
-        } else {
-            Pattern newVersionMatcher = Pattern.compile("java version \"((\\d+).(\\d+).(\\d+).(\\d+))(-(.*))?(\\+[^\"]*)?\"");
-            matcher = newVersionMatcher.matcher(versionOutput);
-            if (matcher.find()) {
-                params.put(".runtime.version", matcher.group(1));
-                params.put(".runtime.version.release", matcher.group(1));
-                params.put(".runtime.version.major", matcher.group(2));
-                params.put(".runtime.version.update", matcher.group(3));
-                params.put(".runtime.version.minor", matcher.group(3));
-                params.put(".runtime.version.security", matcher.group(4));
-                params.put(".runtime.version.patch", matcher.group(5));
-                params.put(".runtime.version.modifiers", matcher.group(7));
-            } else {
-                params.put(".runtime.version", "");
-                params.put(".runtime.version.release", "");
-                params.put(".runtime.version.major", "");
-                params.put(".runtime.version.update", "");
-                params.put(".runtime.version.minor", "");
-                params.put(".runtime.version.security", "");
-                params.put(".runtime.version.patch", "");
-                params.put(".runtime.version.modifiers", "");
-            }
+            return;
+        } 
+        
+        Pattern macJreVersionMatcher = Pattern.compile("java version \"(1.(\\d+).(\\d+).(\\d+))\"");
+        matcher = macJreVersionMatcher.matcher(versionOutput);
+        if (matcher.find()) {
+            params.put(".runtime.version", matcher.group(1));
+            params.put(".runtime.version.release", matcher.group(1));
+            params.put(".runtime.version.major", matcher.group(2));
+            params.put(".runtime.version.update", matcher.group(3));
+            params.put(".runtime.version.minor", matcher.group(3));
+            params.put(".runtime.version.security", matcher.group(3));
+            params.put(".runtime.version.patch", matcher.group(4));
+            params.put(".runtime.version.modifiers", "");
+            return;
         }
+
+        Pattern newVersionMatcher = Pattern.compile("java version \"((\\d+).(\\d+).(\\d+).(\\d+))(-(.*))?(\\+[^\"]*)?\"");
+        matcher = newVersionMatcher.matcher(versionOutput);
+        if (matcher.find()) {
+            params.put(".runtime.version", matcher.group(1));
+            params.put(".runtime.version.release", matcher.group(1));
+            params.put(".runtime.version.major", matcher.group(2));
+            params.put(".runtime.version.update", matcher.group(3));
+            params.put(".runtime.version.minor", matcher.group(3));
+            params.put(".runtime.version.security", matcher.group(4));
+            params.put(".runtime.version.patch", matcher.group(5));
+            params.put(".runtime.version.modifiers", matcher.group(7));
+            return;
+        }
+
+        params.put(".runtime.version", "");
+        params.put(".runtime.version.release", "");
+        params.put(".runtime.version.major", "");
+        params.put(".runtime.version.update", "");
+        params.put(".runtime.version.minor", "");
+        params.put(".runtime.version.security", "");
+        params.put(".runtime.version.patch", "");
+        params.put(".runtime.version.modifiers", "");
     }
 
 
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacAppStoreBundler.java	Fri Oct 02 18:39:46 2015 +0300
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacAppStoreBundler.java	Fri Oct 02 15:33:14 2015 -0600
@@ -290,13 +290,33 @@
                             I18N.getString("error.non-existent-runtime.advice")));
         }
 
-        if (new File(baseDir, "Contents/Home/lib/libjfxmedia_qtkit.dylib").exists()
-            || new File(baseDir, "Contents/Home/jre/lib/libjfxmedia_qtkit.dylib").exists())
-        {
+        int majorVersion;
+        int updateVersion;
+        
+        try {
+            majorVersion = Integer.parseInt(params.get(".runtime.version.major").toString());
+            updateVersion = Integer.parseInt(params.get(".runtime.version.update").toString());
+        } catch (Exception e) {
+            // assume the worst
+            majorVersion = 8;
+            updateVersion = 60;
+        }
+        
+        // Quicktime
+        // before 8u40 it was all of media
+        // after 8u40 QTKit dependencies are isolated in it's own library
+        if (majorVersion == 8 && updateVersion >= 40) {
             rules.add(JreUtils.Rule.suffixNeg("/lib/libjfxmedia_qtkit.dylib"));
         } else {
             rules.add(JreUtils.Rule.suffixNeg("/lib/libjfxmedia.dylib"));
         }
+        
+        // webkit
+        // 8u60 webkit started using an API Apple didn't like
+        if (majorVersion == 8 && updateVersion >= 60) {
+            rules.add(JreUtils.Rule.suffixNeg("/lib/libjfxwebkit.dylib"));
+        }
+        
         return rules.toArray(new JreUtils.Rule[rules.size()]);
     }
 
--- a/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacAppStoreBundlerTest.java	Fri Oct 02 18:39:46 2015 +0300
+++ b/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacAppStoreBundlerTest.java	Fri Oct 02 15:33:14 2015 -0600
@@ -26,6 +26,7 @@
 package com.oracle.tools.packager.mac;
 
 import com.oracle.tools.packager.AbstractBundler;
+import com.oracle.tools.packager.AbstractImageBundler;
 import com.oracle.tools.packager.BundlerParamInfo;
 import com.oracle.tools.packager.ConfigException;
 import com.oracle.tools.packager.IOUtils;
@@ -42,6 +43,8 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.Collection;
@@ -185,7 +188,7 @@
         );
         bundleParams.put(MAC_CF_BUNDLE_VERSION.getID(), "1.0." + new SimpleDateFormat("YYYYMMddHHmm").format(new Date()));
         bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
-        bundleParams.put(IDENTIFIER.getID(), "com.example.javapackager.hello.TestPackager");
+        bundleParams.put(IDENTIFIER.getID(), "com.example.javapacakger.hello.TestPackager");
         bundleParams.put(MacAppBundler.MAC_CATEGORY.getID(), "public.app-category.developer-tools");
         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
         bundleParams.put(VERBOSE.getID(), true);
@@ -200,10 +203,10 @@
         File result = bundler.execute(bundleParams, new File(workDir, "smoke"));
         System.err.println("Bundle at - " + result);
 
-        checkFiles(result);
+        checkFiles(result, runtimeJdk);
     }
 
-    private void checkFiles(File result) throws IOException {
+    private void checkFiles(File result, String runtimeRoot) throws IOException {
         assertNotNull(result);
         assertTrue(result.exists());
         assertTrue(result.length() > MIN_SIZE);
@@ -220,7 +223,34 @@
         Matcher matcher = jreInfoPListPattern.matcher(output);
         assertTrue("Insure that info.plist is packed in for embedded jre", matcher.find());
 
-        assertFalse("Insure JFX Media isn't packed in", output.contains("/libjfxmedia_qtkit.dylib"));
+        Map<String, Object> params = new HashMap<>();
+        String version;
+        
+        if (runtimeRoot == null) {
+            version = System.getProperty("java.runtime.version");
+        } else {
+            byte[] infoPlistBytes = Files.readAllBytes(Paths.get(runtimeRoot).getParent().resolve("Info.plist"));
+            String infoPlist = new String(infoPlistBytes);
+
+            Pattern cfBundleVersionMatcher = Pattern.compile("<key>CFBundleVersion</key>\\s*<string>([^<]+)</string>");
+            Matcher m = cfBundleVersionMatcher.matcher(infoPlist);
+            assertTrue("Packed Info.plist presents a java version", m.find());
+            version = m.group(1);
+        }
+        AbstractImageBundler.extractFlagsFromVersion(params, "java version \"" + version + "\"\n");
+
+        int majorVersion = Integer.parseInt(params.get(".runtime.version.major").toString());
+        int updateVersion = Integer.parseInt(params.get(".runtime.version.update").toString());
+        
+        if (majorVersion == 8 && updateVersion >= 40) {
+            assertFalse("Insure JFX Media QuickTime Partition isn't packed in", output.contains("/libjfxmedia_qtkit.dylib"));
+        } else {
+            assertFalse("Insure JFX Media isn't packed in", output.contains("/libjfxmedia.dylib"));
+        }
+
+        if (majorVersion == 8 && updateVersion >= 60) {
+            assertFalse("Insure WebView library isn't packed in", output.contains("/libjfxwebkit.dylib"));
+        }
     }
 
     @Test
@@ -291,7 +321,7 @@
         File result = bundler.execute(bundleParams, new File(workDir, "everything"));
         System.err.println("Bundle at - " + result);
 
-        checkFiles(result);
+        checkFiles(result, runtimeJdk);
     }
 
     /**
@@ -320,7 +350,7 @@
                         new HashSet<>(Arrays.asList(fakeMainJar)))
         );
         bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
-        bundleParams.put(IDENTIFIER.getID(), "com.example.javapackager.hello.TestPackager");
+        bundleParams.put(IDENTIFIER.getID(), "com.example.javapacakger.hello.TestPackager");
         bundleParams.put(MacAppBundler.MAC_CATEGORY.getID(), "public.app-category.developer-tools");
         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
         bundleParams.put(VERBOSE.getID(), true);
@@ -332,7 +362,7 @@
         File result = bundler.execute(bundleParams, new File(workDir, "jre"));
         System.err.println("Bundle at - " + result);
 
-        checkFiles(result);
+        checkFiles(result, runtimeJre);
 
     }
 
@@ -355,7 +385,7 @@
                         new HashSet<>(Arrays.asList(fakeMainJar)))
         );
         bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
-        bundleParams.put(IDENTIFIER.getID(), "com.example.javapackager.hello.TestPackager");
+        bundleParams.put(IDENTIFIER.getID(), "com.example.javapacakger.hello.TestPackager");
         bundleParams.put(MacAppBundler.MAC_CATEGORY.getID(), "public.app-category.developer-tools");
         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
         bundleParams.put(VERBOSE.getID(), true);