changeset 59250:d56c192d967d

8234867: Issue warning for mutually exclusive options on jpackage command line Reviewed-by: prr, asemenyuk, almatvee
author herrick
date Tue, 10 Dec 2019 08:15:45 -0500
parents d1688b8d1516
children 32d978ba562f
files src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/Arguments.java src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources.properties src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources_ja.properties src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources_zh_CN.properties
diffstat 4 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/Arguments.java	Tue Dec 10 08:12:29 2019 -0500
+++ b/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/Arguments.java	Tue Dec 10 08:15:45 2019 -0500
@@ -565,11 +565,24 @@
                 }
             }
         }
-        if (installerOnly && hasRuntime) {
-            // note --runtime-image is only for image or runtime installer.
-            throw new PackagerException("ERR_InvalidTypeOption",
-                    CLIOptions.PREDEFINED_RUNTIME_IMAGE.getIdWithPrefix(),
-                    ptype);
+        if (hasRuntime) {
+            if (hasAppImage) {
+                // note --runtime-image is only for image or runtime installer.
+                throw new PackagerException("ERR_MutuallyExclusiveOptions",
+                        CLIOptions.PREDEFINED_RUNTIME_IMAGE.getIdWithPrefix(),
+                        CLIOptions.PREDEFINED_APP_IMAGE.getIdWithPrefix());
+            }
+            if (allOptions.contains(CLIOptions.ADD_MODULES)) {
+                throw new PackagerException("ERR_MutuallyExclusiveOptions",
+                        CLIOptions.PREDEFINED_RUNTIME_IMAGE.getIdWithPrefix(),
+                        CLIOptions.ADD_MODULES.getIdWithPrefix());
+            }
+            if (allOptions.contains(CLIOptions.BIND_SERVICES)) {
+                throw new PackagerException("ERR_MutuallyExclusiveOptions",
+                        CLIOptions.PREDEFINED_RUNTIME_IMAGE.getIdWithPrefix(),
+                        CLIOptions.BIND_SERVICES.getIdWithPrefix());
+            }
+
         }
         if (hasMainJar && hasMainModule) {
             throw new PackagerException("ERR_BothMainJarAndModule");
--- a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources.properties	Tue Dec 10 08:12:29 2019 -0500
+++ b/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources.properties	Tue Dec 10 08:15:45 2019 -0500
@@ -72,6 +72,7 @@
 ERR_UnsupportedOption=Error: Option [{0}] is not valid on this platform
 ERR_InvalidTypeOption=Error: Option [{0}] is not valid with type [{1}]
 ERR_NoInstallerEntryPoint=Error: Option [{0}] is not valid without --module or --main-jar entry point option
+ERR_MutuallyExclusiveOptions="Error: Mutually exclusive options [{0}] and [{1}]
 
 ERR_MissingArgument=Error: Missing argument: {0}
 ERR_MissingAppResources=Error: No application jars found
--- a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources_ja.properties	Tue Dec 10 08:12:29 2019 -0500
+++ b/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources_ja.properties	Tue Dec 10 08:15:45 2019 -0500
@@ -72,6 +72,7 @@
 ERR_UnsupportedOption=Error: Option [{0}] is not valid on this platform
 ERR_InvalidTypeOption=Error: Option [{0}] is not valid with type [{1}]
 ERR_NoInstallerEntryPoint=Error: Option [{0}] is not valid without --module or --main-jar entry point option
+ERR_MutuallyExclusiveOptions="Error: Mutually exclusive options [{0}] and [{1}]
 
 ERR_MissingArgument=Error: Missing argument: {0}
 ERR_MissingAppResources=Error: No application jars found
--- a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources_zh_CN.properties	Tue Dec 10 08:12:29 2019 -0500
+++ b/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources_zh_CN.properties	Tue Dec 10 08:15:45 2019 -0500
@@ -72,6 +72,7 @@
 ERR_UnsupportedOption=Error: Option [{0}] is not valid on this platform
 ERR_InvalidTypeOption=Error: Option [{0}] is not valid with type [{1}]
 ERR_NoInstallerEntryPoint=Error: Option [{0}] is not valid without --module or --main-jar entry point option
+ERR_MutuallyExclusiveOptions="Error: Mutually exclusive options [{0}] and [{1}]
 
 ERR_MissingArgument=Error: Missing argument: {0}
 ERR_MissingAppResources=Error: No application jars found