changeset 7111:2ca812fcee42

RT-37217:mac packaging fails when RUNTIME option is passed Summary: the multiple instances of a RUNTIME bundle arg that could adjust the default value resulted in some execution order dependant strangeness. So we get rid of the standard RUNTIME and just use the platform specific ones when needed.
author shemnon
date Thu, 22 May 2014 11:26:37 -0600
parents 90605ca72ec6
children 696a65456d79
files modules/fxpackager/src/main/java/com/oracle/tools/packager/AbstractBundler.java modules/fxpackager/src/main/java/com/oracle/tools/packager/StandardBundlerParam.java modules/fxpackager/src/main/java/com/oracle/tools/packager/linux/LinuxAppBundler.java modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacAppBundler.java modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WinAppBundler.java modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WindowsBundlerParam.java modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/PackagerLib.java modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/bundlers/BundleParams.java modules/fxpackager/src/main/native/launcher/mac/main.m modules/fxpackager/src/main/resources/com/oracle/tools/packager/linux/LinuxAppBundler.properties modules/fxpackager/src/main/resources/com/oracle/tools/packager/mac/MacAppBundler.properties modules/fxpackager/src/main/resources/com/oracle/tools/packager/windows/WindowsBundlerParam.properties modules/fxpackager/src/test/java/com/oracle/tools/packager/windows/WinAppBundlerTest.java modules/fxpackager/src/test/java/com/oracle/tools/packager/windows/WinExeBundlerTest.java modules/fxpackager/src/test/java/com/oracle/tools/packager/windows/WinMsiBundlerTest.java
diffstat 15 files changed, 96 insertions(+), 80 deletions(-) [+]
line wrap: on
line diff
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/AbstractBundler.java	Thu May 22 10:12:44 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/AbstractBundler.java	Thu May 22 11:26:37 2014 -0600
@@ -57,8 +57,7 @@
     protected Class baseResourceLoader = null;
     
     //helper method to test if required files are present in the runtime
-    public void testRuntime(Map<String, ? super Object> p, String[] file) throws ConfigException {
-        RelativeFileSet runtime = StandardBundlerParam.RUNTIME.fetchFrom(p);
+    public void testRuntime(RelativeFileSet runtime, String[] file) throws ConfigException {
         if (runtime == null) {
             return; //null runtime is ok (request to use system)
         }
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/StandardBundlerParam.java	Thu May 22 10:12:44 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/StandardBundlerParam.java	Thu May 22 11:26:37 2014 -0600
@@ -57,16 +57,6 @@
         this.stringConverter = stringConverter;
     }
 
-    public static final StandardBundlerParam<RelativeFileSet> RUNTIME =
-            new StandardBundlerParam<>(
-                    I18N.getString("param.runtime.name"),
-                    I18N.getString("param.runtime.description"),
-                    BundleParams.PARAM_RUNTIME,
-                    RelativeFileSet.class,
-                    params -> null,
-                    (s, p) -> null
-            );
-
     public static final StandardBundlerParam<RelativeFileSet> APP_RESOURCES =
             new StandardBundlerParam<>(
                     I18N.getString("param.app-resources.name"),
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/linux/LinuxAppBundler.java	Thu May 22 10:12:44 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/linux/LinuxAppBundler.java	Thu May 22 11:26:37 2014 -0600
@@ -35,6 +35,7 @@
 import com.oracle.tools.packager.IOUtils;
 import com.oracle.tools.packager.RelativeFileSet;
 import com.oracle.tools.packager.UnsupportedPlatformException;
+import com.sun.javafx.tools.packager.bundlers.BundleParams;
 
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -121,9 +122,9 @@
     );
 
     public static final BundlerParamInfo<RelativeFileSet> LINUX_RUNTIME = new StandardBundlerParam<>(
-            RUNTIME.getName(),
-            RUNTIME.getDescription(),
-            RUNTIME.getID(),
+            I18N.getString("param.runtime.name"),
+            I18N.getString("param.runtime.description"),
+            BundleParams.PARAM_RUNTIME,
             RelativeFileSet.class,
             params -> JreUtils.extractJreAsRelativeFileSet(System.getProperty("java.home"),
                     LINUX_JRE_RULES.fetchFrom(params)),
@@ -169,9 +170,9 @@
 
         //validate required inputs
         if (USE_FX_PACKAGING.fetchFrom(p)) {
-            testRuntime(p, new String[] {"lib/ext/jfxrt.jar", "lib/jfxrt.jar"});
+            testRuntime(LINUX_RUNTIME.fetchFrom(p), new String[] {"lib/ext/jfxrt.jar", "lib/jfxrt.jar"});
         }
-        testRuntime(p, new String[] { "lib/rt.jar" });
+        testRuntime(LINUX_RUNTIME.fetchFrom(p), new String[] { "lib/rt.jar" });
 
         return true;
     }
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacAppBundler.java	Thu May 22 10:12:44 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacAppBundler.java	Thu May 22 11:26:37 2014 -0600
@@ -226,9 +226,9 @@
     );
 
     public static final BundlerParamInfo<RelativeFileSet> MAC_RUNTIME = new StandardBundlerParam<>(
-            RUNTIME.getName(),
-            RUNTIME.getDescription(),
-            RUNTIME.getID(),
+            I18N.getString("param.runtime.name"),
+            I18N.getString("param.runtime.description"),
+            BundleParams.PARAM_RUNTIME,
             RelativeFileSet.class,
             params -> extractMacRuntime(System.getProperty("java.home"), params),
             MacAppBundler::extractMacRuntime
@@ -328,7 +328,7 @@
 
         //validate required inputs
         if (USE_FX_PACKAGING.fetchFrom(p)) {
-            testRuntime(p, new String[] {"Contents/Home/jre/lib/ext/jfxrt.jar", "Contents/Home/jre/lib/jfxrt.jar"});
+            testRuntime(MAC_RUNTIME.fetchFrom(p), new String[] {"Contents/Home/jre/lib/ext/jfxrt.jar", "Contents/Home/jre/lib/jfxrt.jar"});
         }
 
         return true;
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WinAppBundler.java	Thu May 22 10:12:44 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WinAppBundler.java	Thu May 22 11:26:37 2014 -0600
@@ -43,10 +43,10 @@
 import java.text.MessageFormat;
 import java.util.*;
 
-import static com.oracle.tools.packager.JreUtils.*;
 import static com.oracle.tools.packager.StandardBundlerParam.*;
 import static com.oracle.tools.packager.windows.WindowsBundlerParam.BIT_ARCH_64;
 import static com.oracle.tools.packager.windows.WindowsBundlerParam.BIT_ARCH_64_RUNTIME;
+import static com.oracle.tools.packager.windows.WindowsBundlerParam.WIN_RUNTIME;
 
 public class WinAppBundler extends AbstractBundler {
 
@@ -65,52 +65,6 @@
             },
             (s, p) -> null);
 
-    //Subsetting of JRE is restricted.
-    //JRE README defines what is allowed to strip:
-    //   http://www.oracle.com/technetwork/java/javase/jre-7-readme-430162.html //TODO update when 8 goes GA
-    public static final BundlerParamInfo<Rule[]> WIN_JRE_RULES = new StandardBundlerParam<>(
-            "",
-            "",
-            ".win.runtime.rules",
-            Rule[].class,
-            params -> new Rule[]{
-                Rule.prefixNeg("\\bin\\new_plugin"),
-                Rule.prefixNeg("\\lib\\deploy"),
-                Rule.suffixNeg(".pdb"),
-                Rule.suffixNeg(".map"),
-                Rule.suffixNeg("axbridge.dll"),
-                Rule.suffixNeg("eula.dll"),
-                Rule.substrNeg("javacpl"),
-                Rule.suffixNeg("wsdetect.dll"),
-                Rule.substrNeg("eployjava1.dll"), //NP and IE versions
-                Rule.substrNeg("bin\\jp2"),
-                Rule.substrNeg("bin\\jpi"),
-                //Rule.suffixNeg("lib\\ext"), //need some of jars there for https to work
-                Rule.suffixNeg("ssv.dll"),
-                Rule.substrNeg("npjpi"),
-                Rule.substrNeg("npoji"),
-                Rule.suffixNeg(".exe"),
-                //keep core deploy files as JavaFX APIs use them
-                //Rule.suffixNeg("deploy.dll"),
-                Rule.suffixNeg("deploy.jar"),
-                //Rule.suffixNeg("javaws.jar"),
-                //Rule.suffixNeg("plugin.jar"),
-                Rule.suffix(".jar")
-            },
-            (s, p) -> null
-    );
-
-    public static final BundlerParamInfo<RelativeFileSet> WIN_RUNTIME = new StandardBundlerParam<>(
-            RUNTIME.getName(),
-            RUNTIME.getDescription(),
-            RUNTIME.getID(),
-            RelativeFileSet.class,
-            params -> extractJreAsRelativeFileSet(System.getProperty("java.home"),
-                    WIN_JRE_RULES.fetchFrom(params)),
-            (s, p) -> extractJreAsRelativeFileSet(s,
-                    WIN_JRE_RULES.fetchFrom(p))
-    );
-
     private final static String EXECUTABLE_NAME = "WinLauncher.exe";
 
     private static final String TOOL_ICON_SWAP="IconSwap.exe";
@@ -205,7 +159,7 @@
 
         //validate required inputs
         if (USE_FX_PACKAGING.fetchFrom(p)) {
-            testRuntime(p, new String[] {"lib/ext/jfxrt.jar", "lib/jfxrt.jar"});
+            testRuntime(WIN_RUNTIME.fetchFrom(p), new String[] {"lib/ext/jfxrt.jar", "lib/jfxrt.jar"});
         }
 
         //validate runtime bit-architectire
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WindowsBundlerParam.java	Thu May 22 10:12:44 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WindowsBundlerParam.java	Thu May 22 11:26:37 2014 -0600
@@ -26,10 +26,12 @@
 package com.oracle.tools.packager.windows;
 
 import com.oracle.tools.packager.BundlerParamInfo;
+import com.oracle.tools.packager.JreUtils;
 import com.oracle.tools.packager.StandardBundlerParam;
 import com.oracle.tools.packager.Log;
 import com.oracle.tools.packager.IOUtils;
 import com.oracle.tools.packager.RelativeFileSet;
+import com.sun.javafx.tools.packager.bundlers.BundleParams;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -42,6 +44,8 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import static com.oracle.tools.packager.JreUtils.extractJreAsRelativeFileSet;
+
 
 public class WindowsBundlerParam<T> extends StandardBundlerParam<T> {
     
@@ -102,12 +106,58 @@
                     params -> {extractFlagsFromRuntime(params); return "64".equals(params.get(".runtime.bit-arch"));},
                     (s, p) -> Boolean.valueOf(s)
             );
-       
+
+    //Subsetting of JRE is restricted.
+    //JRE README defines what is allowed to strip:
+    //   http://www.oracle.com/technetwork/java/javase/jre-7-readme-430162.html //TODO update when 8 goes GA
+    public static final BundlerParamInfo<JreUtils.Rule[]> WIN_JRE_RULES = new StandardBundlerParam<>(
+            "",
+            "",
+            ".win.runtime.rules",
+            JreUtils.Rule[].class,
+            params -> new JreUtils.Rule[]{
+                    JreUtils.Rule.prefixNeg("\\bin\\new_plugin"),
+                    JreUtils.Rule.prefixNeg("\\lib\\deploy"),
+                    JreUtils.Rule.suffixNeg(".pdb"),
+                    JreUtils.Rule.suffixNeg(".map"),
+                    JreUtils.Rule.suffixNeg("axbridge.dll"),
+                    JreUtils.Rule.suffixNeg("eula.dll"),
+                    JreUtils.Rule.substrNeg("javacpl"),
+                    JreUtils.Rule.suffixNeg("wsdetect.dll"),
+                    JreUtils.Rule.substrNeg("eployjava1.dll"), //NP and IE versions
+                    JreUtils.Rule.substrNeg("bin\\jp2"),
+                    JreUtils.Rule.substrNeg("bin\\jpi"),
+                    //Rule.suffixNeg("lib\\ext"), //need some of jars there for https to work
+                    JreUtils.Rule.suffixNeg("ssv.dll"),
+                    JreUtils.Rule.substrNeg("npjpi"),
+                    JreUtils.Rule.substrNeg("npoji"),
+                    JreUtils.Rule.suffixNeg(".exe"),
+                    //keep core deploy files as JavaFX APIs use them
+                    //Rule.suffixNeg("deploy.dll"),
+                    JreUtils.Rule.suffixNeg("deploy.jar"),
+                    //Rule.suffixNeg("javaws.jar"),
+                    //Rule.suffixNeg("plugin.jar"),
+                    JreUtils.Rule.suffix(".jar")
+            },
+            (s, p) -> null
+    );
+
+    public static final BundlerParamInfo<RelativeFileSet> WIN_RUNTIME = new StandardBundlerParam<>(
+            I18N.getString("param.runtime.name"),
+            I18N.getString("param.runtime.description"),
+            BundleParams.PARAM_RUNTIME,
+            RelativeFileSet.class,
+            params -> extractJreAsRelativeFileSet(System.getProperty("java.home"),
+                    WIN_JRE_RULES.fetchFrom(params)),
+            (s, p) -> extractJreAsRelativeFileSet(s,
+                    WIN_JRE_RULES.fetchFrom(p))
+    );
+
     public static void extractFlagsFromRuntime(Map<String, ? super Object> params) {
         if (params.containsKey(".runtime.autodetect")) return;
         
         params.put(".runtime.autodetect", "attempted");
-        RelativeFileSet runtime = RUNTIME.fetchFrom(params);
+        RelativeFileSet runtime = WIN_RUNTIME.fetchFrom(params);
         String commandline;
         if (runtime == null) {
             //its ok, request to use system JRE
--- a/modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/PackagerLib.java	Thu May 22 10:12:44 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/PackagerLib.java	Thu May 22 11:26:37 2014 -0600
@@ -92,8 +92,6 @@
 import java.util.zip.ZipOutputStream;
 import sun.misc.BASE64Encoder;
 
-import static com.oracle.tools.packager.StandardBundlerParam.*;
-
 public class PackagerLib {
     public static final String JAVAFX_VERSION = "8.0";
 
@@ -489,8 +487,8 @@
     private void generateNativeBundles(File outdir, Map<String, ? super Object> params, String bundleType, String bundleFormat) throws PackagerException {
         outdir = new File(outdir, "bundles");
 
-        if (params.containsKey(RUNTIME.getID())) {
-            RelativeFileSet runtime = RUNTIME.fetchFrom(params);
+        if (params.containsKey(BundleParams.PARAM_RUNTIME)) {
+            RelativeFileSet runtime = BundleParams.getRuntime(params);
             if (runtime == null) {
                 com.oracle.tools.packager.Log.info(bundle.getString("MSG_NoJREPackaged"));
             } else {
--- a/modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/bundlers/BundleParams.java	Thu May 22 10:12:44 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/bundlers/BundleParams.java	Thu May 22 11:26:37 2014 -0600
@@ -26,6 +26,9 @@
 package com.sun.javafx.tools.packager.bundlers;
 
 import com.oracle.tools.packager.*;
+import com.oracle.tools.packager.linux.LinuxAppBundler;
+import com.oracle.tools.packager.mac.MacAppBundler;
+import com.oracle.tools.packager.windows.WindowsBundlerParam;
 import com.sun.javafx.tools.packager.bundlers.Bundler.BundleType;
 
 import java.io.File;
@@ -231,7 +234,20 @@
     }
     
     public com.oracle.tools.packager.RelativeFileSet getRuntime() {
-        return fetchParam(RUNTIME);
+        return getRuntime(params);
+    }
+
+    public static com.oracle.tools.packager.RelativeFileSet getRuntime(Map<String, ? super Object> params) {
+        String os = System.getProperty("os.name").toLowerCase();
+        if (os.startsWith("linux")) {
+            return LinuxAppBundler.LINUX_RUNTIME.fetchFrom(params);
+        } else if (os.contains("os x")) {
+            return MacAppBundler.MAC_RUNTIME.fetchFrom(params);
+        } else if (os.startsWith("win")) {
+            return WindowsBundlerParam.WIN_RUNTIME.fetchFrom(params);
+        } else {
+            return null;
+        }
     }
 
     public boolean isShortcutHint() {
--- a/modules/fxpackager/src/main/native/launcher/mac/main.m	Thu May 22 10:12:44 2014 -0700
+++ b/modules/fxpackager/src/main/native/launcher/mac/main.m	Thu May 22 11:26:37 2014 -0600
@@ -329,7 +329,7 @@
     //Add preferences ID
     NSString *preferencesID = [infoDictionary objectForKey:@JVM_PREFERENCES_ID];
     if (preferencesID != nil) {
-        [expandedOptions addObject: [@"-Djvm.preferences.id=" stringByAppendingString: preferencesID]];
+        [expandedOptions addObject: [@"-Dapp.preferences.id=" stringByAppendingString: preferencesID]];
     }
 
     for (id option in options) {
--- a/modules/fxpackager/src/main/resources/com/oracle/tools/packager/linux/LinuxAppBundler.properties	Thu May 22 10:12:44 2014 -0700
+++ b/modules/fxpackager/src/main/resources/com/oracle/tools/packager/linux/LinuxAppBundler.properties	Thu May 22 11:26:37 2014 -0600
@@ -10,6 +10,9 @@
 param.app-fs-name.name=App File System Name
 param.app-fs-name.description=The name of the application suitable for file system use.  Typically this is just letters, numbers, dots, and dashes.
 
+param.runtime.name=JRE
+param.runtime.description=The Java Runtime to co-bundle.  The default value is the current JRE running the bundler.  A value of null will cause no JRE to be co-bundled and the system JRE will be used to launch the application.
+
 error.parameters-null=Parameters map is null.
 error.parameters-null.advice=Pass in a non-null parameters map.
 error.no-linux-resources=This copy of ant-javafx.jar does not support Linux.
--- a/modules/fxpackager/src/main/resources/com/oracle/tools/packager/mac/MacAppBundler.properties	Thu May 22 10:12:44 2014 -0700
+++ b/modules/fxpackager/src/main/resources/com/oracle/tools/packager/mac/MacAppBundler.properties	Thu May 22 11:26:37 2014 -0600
@@ -28,6 +28,8 @@
 param.default-icon-icns=Default Icon
 param.default-icon-icns.description=The Default Icon for when a user does not specify an icns file.
 
+param.runtime.name=JRE
+param.runtime.description=The Java Runtime to co-bundle.  The default value is the current JRE running the bundler.  A value of null will cause no JRE to be co-bundled and the system JRE will be used to launch the application.
 
 error.no-application-jar=Main application jar is missing.
 error.no-application-jar.advice=Make sure to use fx\:jar task to create main application jar.
--- a/modules/fxpackager/src/main/resources/com/oracle/tools/packager/windows/WindowsBundlerParam.properties	Thu May 22 10:12:44 2014 -0700
+++ b/modules/fxpackager/src/main/resources/com/oracle/tools/packager/windows/WindowsBundlerParam.properties	Thu May 22 11:26:37 2014 -0600
@@ -10,3 +10,6 @@
 
 param.installer-name.name=Installer Name
 param.installer-name.description=The filename of the generated installer without the file type extension.  Default is <App Name>-<Version>.
+
+param.runtime.name=JRE
+param.runtime.description=The Java Runtime to co-bundle.  The default value is the current JRE running the bundler.  A value of null will cause no JRE to be co-bundled and the system JRE will be used to launch the application.
--- a/modules/fxpackager/src/test/java/com/oracle/tools/packager/windows/WinAppBundlerTest.java	Thu May 22 10:12:44 2014 -0700
+++ b/modules/fxpackager/src/test/java/com/oracle/tools/packager/windows/WinAppBundlerTest.java	Thu May 22 11:26:37 2014 -0600
@@ -52,7 +52,7 @@
 
 import static com.oracle.tools.packager.StandardBundlerParam.*;
 import static com.oracle.tools.packager.windows.WinAppBundler.ICON_ICO;
-import static com.oracle.tools.packager.windows.WinAppBundler.WIN_RUNTIME;
+import static com.oracle.tools.packager.windows.WindowsBundlerParam.WIN_RUNTIME;
 import static org.junit.Assert.*;
 
 public class WinAppBundlerTest {
--- a/modules/fxpackager/src/test/java/com/oracle/tools/packager/windows/WinExeBundlerTest.java	Thu May 22 10:12:44 2014 -0700
+++ b/modules/fxpackager/src/test/java/com/oracle/tools/packager/windows/WinExeBundlerTest.java	Thu May 22 11:26:37 2014 -0600
@@ -50,7 +50,7 @@
 
 import static com.oracle.tools.packager.StandardBundlerParam.*;
 import static com.oracle.tools.packager.windows.WinAppBundler.ICON_ICO;
-import static com.oracle.tools.packager.windows.WinAppBundler.WIN_RUNTIME;
+import static com.oracle.tools.packager.windows.WindowsBundlerParam.WIN_RUNTIME;
 import static com.oracle.tools.packager.windows.WindowsBundlerParam.MENU_GROUP;
 import static org.junit.Assert.*;
 
--- a/modules/fxpackager/src/test/java/com/oracle/tools/packager/windows/WinMsiBundlerTest.java	Thu May 22 10:12:44 2014 -0700
+++ b/modules/fxpackager/src/test/java/com/oracle/tools/packager/windows/WinMsiBundlerTest.java	Thu May 22 11:26:37 2014 -0600
@@ -50,7 +50,7 @@
 
 import static com.oracle.tools.packager.StandardBundlerParam.*;
 import static com.oracle.tools.packager.windows.WinAppBundler.ICON_ICO;
-import static com.oracle.tools.packager.windows.WinAppBundler.WIN_RUNTIME;
+import static com.oracle.tools.packager.windows.WindowsBundlerParam.WIN_RUNTIME;
 import static com.oracle.tools.packager.windows.WindowsBundlerParam.MENU_GROUP;
 import static org.junit.Assert.*;