< prev index next >

src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java

Print this page

        

@@ -72,11 +72,10 @@
     // regexp for parsing args (for example, for additional launchers)
     private static Pattern pattern = Pattern.compile(
           "(?:(?:([\"'])(?:\\\\\\1|.)*?(?:\\1|$))|(?:\\\\[\"'\\s]|[^\\s]))++");
 
     private DeployParams deployParams = null;
-    private String packageType = null;
 
     private int pos = 0;
     private List<String> argList = null;
 
     private List<CLIOptions> allOptions = null;

@@ -117,22 +116,19 @@
         Log.verbose ("\njpackage argument list: \n" + argList + "\n");
         pos = 0;
 
         deployParams = new DeployParams();
 
-        packageType = null;
-
         allOptions = new ArrayList<>();
 
         addLaunchers = new ArrayList<>();
     }
 
     // CLIOptions is public for DeployParamsTest
     public enum CLIOptions {
         PACKAGE_TYPE("package-type", OptionCategories.PROPERTY, () -> {
-            context().packageType = popArg();
-            context().deployParams.setTargetFormat(context().packageType);
+            context().deployParams.setTargetFormat(popArg());
         }),
 
         INPUT ("input", "i", OptionCategories.PROPERTY, () -> {
             context().input = popArg();
             setOptionValue("input", context().input);

@@ -528,13 +524,13 @@
             return false;
         }
     }
 
     private void validateArguments() throws PackagerException {
-        String packageType = deployParams.getTargetFormat();
-        String ptype = (packageType != null) ? packageType : "default";
-        boolean imageOnly = (packageType == null);
+        String type = deployParams.getTargetFormat();
+        String ptype = (type != null) ? type : "default";
+        boolean imageOnly = deployParams.isTargetAppImage();
         boolean hasAppImage = allOptions.contains(
                 CLIOptions.PREDEFINED_APP_IMAGE);
         boolean hasRuntime = allOptions.contains(
                 CLIOptions.PREDEFINED_RUNTIME_IMAGE);
         boolean installerOnly = !imageOnly && hasAppImage;

@@ -548,11 +544,11 @@
                         option.getIdWithPrefix());
             }
             if (imageOnly) {
                 if (!ValidOptions.checkIfImageSupported(option)) {
                     throw new PackagerException("ERR_InvalidTypeOption",
-                        option.getIdWithPrefix(), packageType);
+                        option.getIdWithPrefix(), type);
                 }
             } else if (installerOnly || runtimeInstaller) {
                 if (!ValidOptions.checkIfInstallerSupported(option)) {
                     if (runtimeInstaller) {
                         throw new PackagerException("ERR_NoInstallerEntryPoint",

@@ -577,22 +573,31 @@
             throw new PackagerException("ERR_NoEntryPoint");
         }
     }
 
     private jdk.jpackage.internal.Bundler getPlatformBundler() {
-        String bundleType = (packageType == null ? "IMAGE" : "INSTALLER");
+        boolean appImage = deployParams.isTargetAppImage();
+        String type = deployParams.getTargetFormat();
+        String bundleType = (appImage ?  "IMAGE" : "INSTALLER");
+        jdk.jpackage.internal.Bundler savedBundler = null;
 
         for (jdk.jpackage.internal.Bundler bundler :
                 Bundlers.createBundlersInstance().getBundlers(bundleType)) {
-            if ((packageType == null) ||
-                     packageType.equalsIgnoreCase(bundler.getID())) {
                  if (bundler.supported(runtimeInstaller)) {
+                 if (type == null) {
+                     if (bundler.isDefault()) {
+                         return bundler;
+                     } else {
+                         savedBundler = bundler;
+                     }
+                 } else if (appImage ||
+                         type.equalsIgnoreCase(bundler.getID())) {
                      return bundler;
                  }
             }
         }
-        return null;
+        return savedBundler;
     }
 
     private void generateBundle(Map<String,? super Object> params)
             throws PackagerException {
 
< prev index next >