8220505: Allow building available installers when --installer-type not specified JDK-8200758-branch
authorherrick
Wed, 13 Mar 2019 07:46:52 -0400
branchJDK-8200758-branch
changeset 57261 13b6672477df
parent 57259 a84c657c713d
child 57262 e2b18d61132f
8220505: Allow building available installers when --installer-type not specified Reviewed-by: almatvee
src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_ja.properties
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_zh_CN.properties
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_ja.properties
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_zh_CN.properties
src/jdk.jpackage/share/classes/jdk/jpackage/main/Main.java
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java	Mon Mar 11 21:04:21 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java	Wed Mar 13 07:46:52 2019 -0400
@@ -579,9 +579,13 @@
             if (Log.isVerbose()) {
                 throw e;
             } else {
-                Log.error(e.getMessage());
+                String msg1 = e.getMessage();
+                Log.error(msg1);
                 if (e.getCause() != null && e.getCause() != e) {
-                    Log.error(e.getCause().getMessage());
+                    String msg2 = e.getCause().getMessage();
+                    if (!msg1.contains(msg2)) {
+                        Log.error(msg2);
+                    }
                 }
                 return false;
             }
@@ -671,6 +675,7 @@
             throw new PackagerException("ERR_InvalidInstallerType",
                     deployParams.getTargetFormat());
         }
+        PackagerException pe = null;
         for (jdk.jpackage.internal.Bundler bundler : bundlers) {
             Map<String, ? super Object> localParams = new HashMap<>(params);
             try {
@@ -686,25 +691,33 @@
                     }
                     bundleCreated = true; // at least one bundle was created
                 }
-            } catch (UnsupportedPlatformException e) {
-                throw new PackagerException(e,
-                        "MSG_BundlerPlatformException",
-                        bundler.getName());
+                Log.verbose(MessageFormat.format(
+                        I18N.getString("message.bundle-created"),
+                        bundler.getName()));
+            } catch (UnsupportedPlatformException upe) {
+                Log.debug(upe);
+                if (pe == null) {
+                    pe = new PackagerException(upe,
+                            "MSG_BundlerPlatformException", bundler.getName());
+                }
             } catch (ConfigException e) {
                 Log.debug(e);
-                if (e.getAdvice() != null) {
-                    throw new PackagerException(e,
+                if (pe == null) {
+                    pe = (e.getAdvice() != null) ?
+                            new PackagerException(e,
                             "MSG_BundlerConfigException",
-                            bundler.getName(), e.getMessage(), e.getAdvice());
-                } else {
-                    throw new PackagerException(e,
+                            bundler.getName(), e.getMessage(), e.getAdvice()) :
+                            new PackagerException(e,
                            "MSG_BundlerConfigExceptionNoAdvice",
                             bundler.getName(), e.getMessage());
                 }
             } catch (RuntimeException re) {
                 Log.debug(re);
-                throw new PackagerException(re, "MSG_BundlerRuntimeException",
-                        bundler.getName(), re.toString());
+                if (pe == null) {
+                    pe = new PackagerException(re,
+                            "MSG_BundlerRuntimeException",
+                            bundler.getName(), re.toString());
+                }
             } finally {
                 if (userProvidedBuildRoot) {
                     Log.verbose(MessageFormat.format(
@@ -713,7 +726,10 @@
                 }
             }
         }
-
+        if (pe != null) {
+            // throw packager exception only after trying all bundlers
+            throw pe;
+        }
         return bundleCreated;
     }
 
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties	Mon Mar 11 21:04:21 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties	Wed Mar 13 07:46:52 2019 -0400
@@ -84,7 +84,7 @@
 \          Vendor of the application\n\
 \  --verbose\n\
 \          Enables verbose output\n\
-\  --version -v\n\
+\  --version\n\
 \          Print the product version to the output stream and exit\n\
 \n\
 \Options for creating the runtime image:\n\
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_ja.properties	Mon Mar 11 21:04:21 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_ja.properties	Wed Mar 13 07:46:52 2019 -0400
@@ -84,7 +84,7 @@
 \          Vendor of the application\n\
 \  --verbose\n\
 \          Enables verbose output\n\
-\  --version -v\n\
+\  --version\n\
 \          Print the product version to the output stream and exit\n\
 \n\
 \Options for creating the runtime image:\n\
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_zh_CN.properties	Mon Mar 11 21:04:21 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_zh_CN.properties	Wed Mar 13 07:46:52 2019 -0400
@@ -84,7 +84,7 @@
 \          Vendor of the application\n\
 \  --verbose\n\
 \          Enables verbose output\n\
-\  --version -v\n\
+\  --version\n\
 \          Print the product version to the output stream and exit\n\
 \n\
 \Options for creating the runtime image:\n\
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties	Mon Mar 11 21:04:21 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties	Wed Mar 13 07:46:52 2019 -0400
@@ -42,6 +42,7 @@
 message.runtime-image-dir-does-not-exist=Specified runtime image directory {0}\: {1} does not exists
 message.runtime-image-dir-does-not-exist.advice=Confirm that the value for {0} exists
 message.debug-working-directory=Kept working directory for debug\: {0}
+message.bundle-created=Succeeded in building {0} bundle
 
 error.cannot-create-output-dir=Output directory {0} cannot be created.
 error.cannot-write-to-output-dir=Output directory {0} is not writable.
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_ja.properties	Mon Mar 11 21:04:21 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_ja.properties	Wed Mar 13 07:46:52 2019 -0400
@@ -42,6 +42,7 @@
 message.runtime-image-dir-does-not-exist=Specified runtime image directory {0}\: {1} does not exists
 message.runtime-image-dir-does-not-exist.advice=Confirm that the value for {0} exists
 message.debug-working-directory=Kept working directory for debug\: {0}
+message.bundle-created=Succeeded in building {0} bundle
 
 error.cannot-create-output-dir=Output directory {0} cannot be created.
 error.cannot-write-to-output-dir=Output directory {0} is not writable.
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_zh_CN.properties	Mon Mar 11 21:04:21 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_zh_CN.properties	Wed Mar 13 07:46:52 2019 -0400
@@ -42,6 +42,7 @@
 message.runtime-image-dir-does-not-exist=Specified runtime image directory {0}\: {1} does not exists
 message.runtime-image-dir-does-not-exist.advice=Confirm that the value for {0} exists
 message.debug-working-directory=Kept working directory for debug\: {0}
+message.bundle-created=Succeeded in building {0} bundle
 
 error.cannot-create-output-dir=Output directory {0} cannot be created.
 error.cannot-write-to-output-dir=Output directory {0} is not writable.
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/main/Main.java	Mon Mar 11 21:04:21 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/main/Main.java	Wed Mar 13 07:46:52 2019 -0400
@@ -119,7 +119,7 @@
 
     private static boolean hasVersion(String[] args) {
         for (String a : args) {
-            if ("--version".equals(a) || "-v".equals(a)) {
+            if ("--version".equals(a)) {
                 return true;
             }
         }