src/jdk.packager/share/classes/jdk/packager/internal/Arguments.java
branchJDK-8200758-branch
changeset 56957 2f01969ed7cb
parent 56933 9f59eeb3cc0f
child 56958 8880b21d458d
equal deleted inserted replaced
56949:b06759b804fc 56957:2f01969ed7cb
    80                     INSTALLER_MODE,
    80                     INSTALLER_MODE,
    81                     Boolean.class,
    81                     Boolean.class,
    82                     p -> Boolean.FALSE,
    82                     p -> Boolean.FALSE,
    83                     (s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
    83                     (s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
    84                             true : Boolean.valueOf(s));
    84                             true : Boolean.valueOf(s));
    85     
    85 
    86     public static final BundlerParamInfo<Boolean> CREATE_JRE_INSTALLER =
    86     public static final BundlerParamInfo<Boolean> CREATE_JRE_INSTALLER =
    87             new StandardBundlerParam<>(
    87             new StandardBundlerParam<>(
    88                     I18N.getString("param.create-jre-installer.name"),
    88                     I18N.getString("param.create-jre-installer.name"),
    89                     I18N.getString("param.create-jre-installer.description"),
    89                     I18N.getString("param.create-jre-installer.description"),
    90                     JRE_INSTALLER_MODE,
    90                     JRE_INSTALLER_MODE,
   115     private boolean hasMainModule = false;
   115     private boolean hasMainModule = false;
   116     private boolean hasTargetFormat = false;
   116     private boolean hasTargetFormat = false;
   117     private boolean hasAppImage = false;
   117     private boolean hasAppImage = false;
   118 
   118 
   119     private String mainJarPath = null;
   119     private String mainJarPath = null;
   120     
   120 
   121     private static boolean echo = false;
   121     private static boolean echo = false;
   122     private static boolean verbose = false;
   122     private static boolean verbose = false;
   123     private static boolean jreInstaller = false;
   123     private static boolean jreInstaller = false;
   124 
   124 
   125     private List<jdk.packager.internal.Bundler> platformBundlers = null;
   125     private List<jdk.packager.internal.Bundler> platformBundlers = null;
   165                     prevArg();
   165                     prevArg();
   166                 }
   166                 }
   167             }
   167             }
   168             context().deployParams.setTargetFormat(format);
   168             context().deployParams.setTargetFormat(format);
   169         }),
   169         }),
   170         
   170 
   171         CREATE_JRE_INSTALLER(JRE_INSTALLER_MODE, OptionCategories.MODE, () -> {
   171         CREATE_JRE_INSTALLER(JRE_INSTALLER_MODE, OptionCategories.MODE, () -> {
   172             setOptionValue(JRE_INSTALLER_MODE, true);
   172             setOptionValue(JRE_INSTALLER_MODE, true);
   173             context().bundleType = Bundler.BundleType.INSTALLER;
   173             context().bundleType = Bundler.BundleType.INSTALLER;
   174             String format = "installer";
   174             String format = "installer";
   175             if (hasNextArg()) {
   175             if (hasNextArg()) {
   291             context().secondaryLaunchers.add(
   291             context().secondaryLaunchers.add(
   292                 new SecondaryLauncherArguments(popArg()));
   292                 new SecondaryLauncherArguments(popArg()));
   293         }),
   293         }),
   294 
   294 
   295         BUILD_ROOT ("build-root", OptionCategories.PROPERTY),
   295         BUILD_ROOT ("build-root", OptionCategories.PROPERTY),
   296         
   296 
   297         INSTALL_DIR ("install-dir", OptionCategories.PROPERTY),
   297         INSTALL_DIR ("install-dir", OptionCategories.PROPERTY),
   298 
   298 
   299         ECHO_MODE ("echo-mode", OptionCategories.PROPERTY, () -> {
   299         ECHO_MODE ("echo-mode", OptionCategories.PROPERTY, () -> {
   300             echo = true;
   300             echo = true;
   301             setOptionValue("echo-mode", true);
   301             setOptionValue("echo-mode", true);
   303 
   303 
   304         PREDEFINED_APP_IMAGE ("app-image", OptionCategories.PROPERTY, ()-> {
   304         PREDEFINED_APP_IMAGE ("app-image", OptionCategories.PROPERTY, ()-> {
   305             setOptionValue("app-image", popArg());
   305             setOptionValue("app-image", popArg());
   306             context().hasAppImage = true;
   306             context().hasAppImage = true;
   307         }),
   307         }),
   308         
   308 
   309         PREDEFINED_RUNTIME_IMAGE ("runtime-image", OptionCategories.PROPERTY),
   309         PREDEFINED_RUNTIME_IMAGE ("runtime-image", OptionCategories.PROPERTY),
   310 
   310 
   311         MAIN_JAR ("main-jar", "j", OptionCategories.PROPERTY, () -> {
   311         MAIN_JAR ("main-jar", "j", OptionCategories.PROPERTY, () -> {
   312             context().mainJarPath = popArg();
   312             context().mainJarPath = popArg();
   313             context().hasMainJar = true;
   313             context().hasMainJar = true;
   320         }),
   320         }),
   321 
   321 
   322         ADD_MODULES ("add-modules", OptionCategories.MODULAR),
   322         ADD_MODULES ("add-modules", OptionCategories.MODULAR),
   323 
   323 
   324         MODULE_PATH ("module-path", "p", OptionCategories.MODULAR),
   324         MODULE_PATH ("module-path", "p", OptionCategories.MODULAR),
   325         
   325 
   326         LIMIT_MODULES ("limit-modules", OptionCategories.MODULAR),
   326         LIMIT_MODULES ("limit-modules", OptionCategories.MODULAR),
   327 
   327 
   328         MAC_SIGN ("mac-sign", "s", OptionCategories.PLATFORM_MAC, () -> {
   328         MAC_SIGN ("mac-sign", "s", OptionCategories.PLATFORM_MAC, () -> {
   329             setOptionValue("mac-sign", true);
   329             setOptionValue("mac-sign", true);
   330         }),
   330         }),
   331 
   331 
   332         MAC_BUNDLE_NAME ("mac-bundle-name", OptionCategories.PLATFORM_MAC),
   332         MAC_BUNDLE_NAME ("mac-bundle-name", OptionCategories.PLATFORM_MAC),
   333         
   333 
   334         MAC_BUNDLE_IDENTIFIER("mac-bundle-identifier",
   334         MAC_BUNDLE_IDENTIFIER("mac-bundle-identifier",
   335                     OptionCategories.PLATFORM_MAC),
   335                     OptionCategories.PLATFORM_MAC),
   336 
   336 
   337         MAC_APP_STORE_CATEGORY ("mac-app-store-category",
   337         MAC_APP_STORE_CATEGORY ("mac-app-store-category",
   338                     OptionCategories.PLATFORM_MAC),
   338                     OptionCategories.PLATFORM_MAC),
   365             setOptionValue("win-per-user-install", false);
   365             setOptionValue("win-per-user-install", false);
   366         }),
   366         }),
   367 
   367 
   368         WIN_DIR_CHOOSER ("win-dir-chooser",
   368         WIN_DIR_CHOOSER ("win-dir-chooser",
   369                 OptionCategories.PLATFORM_WIN, () -> {
   369                 OptionCategories.PLATFORM_WIN, () -> {
   370             setOptionValue("win-dir-chooser", true); 
   370             setOptionValue("win-dir-chooser", true);
   371         }),
   371         }),
   372 
   372 
   373         WIN_REGISTRY_NAME ("win-registry-name", OptionCategories.PLATFORM_WIN),
   373         WIN_REGISTRY_NAME ("win-registry-name", OptionCategories.PLATFORM_WIN),
   374 
   374 
   375         WIN_MSI_UPGRADE_UUID ("win-upgrade-uuid",
   375         WIN_MSI_UPGRADE_UUID ("win-upgrade-uuid",
   376                 OptionCategories.PLATFORM_WIN),
   376                 OptionCategories.PLATFORM_WIN),
   377         
   377 
       
   378         WIN_CONSOLE_HINT ("win-console", OptionCategories.PLATFORM_WIN, () -> {
       
   379             setOptionValue("win-console", true);
       
   380         }),
       
   381 
   378         LINUX_BUNDLE_NAME ("linux-bundle-name",
   382         LINUX_BUNDLE_NAME ("linux-bundle-name",
   379                 OptionCategories.PLATFORM_LINUX),
   383                 OptionCategories.PLATFORM_LINUX),
   380 
   384 
   381         LINUX_DEB_MAINTAINER ("linux-deb-maintainer",
   385         LINUX_DEB_MAINTAINER ("linux-deb-maintainer",
   382                 OptionCategories.PLATFORM_LINUX),
   386                 OptionCategories.PLATFORM_LINUX),
   503 
   507 
   504         deployParams = new DeployParams();
   508         deployParams = new DeployParams();
   505         bundleType = Bundler.BundleType.NONE;
   509         bundleType = Bundler.BundleType.NONE;
   506 
   510 
   507         allOptions = new ArrayList<>();
   511         allOptions = new ArrayList<>();
   508         
   512 
   509         secondaryLaunchers = new ArrayList<>();
   513         secondaryLaunchers = new ArrayList<>();
   510     }
   514     }
   511 
   515 
   512     public boolean processArguments() throws Exception {
   516     public boolean processArguments() throws Exception {
   513         try {
   517         try {
   593         CLIOptions mode = allOptions.get(0);
   597         CLIOptions mode = allOptions.get(0);
   594         for (CLIOptions option : allOptions) {
   598         for (CLIOptions option : allOptions) {
   595             if(!ValidOptions.checkIfSupported(mode, option)) {
   599             if(!ValidOptions.checkIfSupported(mode, option)) {
   596               System.out.println("WARNING: argument ["
   600               System.out.println("WARNING: argument ["
   597                       + option.getId() + "] is not "
   601                       + option.getId() + "] is not "
   598                       + "supported for current configuration.");  
   602                       + "supported for current configuration.");
   599             }
   603             }
   600         }
   604         }
   601     }
   605     }
   602 
   606 
   603     private List<jdk.packager.internal.Bundler> getPlatformBundlers() {
   607     private List<jdk.packager.internal.Bundler> getPlatformBundlers() {
   608 
   612 
   609         platformBundlers = new ArrayList<>();
   613         platformBundlers = new ArrayList<>();
   610         for (jdk.packager.internal.Bundler bundler :
   614         for (jdk.packager.internal.Bundler bundler :
   611                 Bundlers.createBundlersInstance().getBundlers(
   615                 Bundlers.createBundlersInstance().getBundlers(
   612                         bundleType.toString())) {
   616                         bundleType.toString())) {
   613             if (hasTargetFormat && deployParams.getTargetFormat() != null && 
   617             if (hasTargetFormat && deployParams.getTargetFormat() != null &&
   614                     !deployParams.getTargetFormat().equalsIgnoreCase(
   618                     !deployParams.getTargetFormat().equalsIgnoreCase(
   615                     bundler.getID())) {
   619                     bundler.getID())) {
   616                 continue;
   620                 continue;
   617             }
   621             }
   618             if (bundler.supported()) {
   622             if (bundler.supported()) {
   741             properties.load(in);
   745             properties.load(in);
   742             in.close();
   746             in.close();
   743         } catch (IOException e) {
   747         } catch (IOException e) {
   744             Log.info("Exception: " + e.getMessage());
   748             Log.info("Exception: " + e.getMessage());
   745         }
   749         }
   746         
   750 
   747         for (final String name: properties.stringPropertyNames()) {
   751         for (final String name: properties.stringPropertyNames()) {
   748             map.put(name, properties.getProperty(name));
   752             map.put(name, properties.getProperty(name));
   749         }
   753         }
   750 
   754 
   751         return map;
   755         return map;
   815 
   819 
   816     private String getMainClassFromManifest() {
   820     private String getMainClassFromManifest() {
   817         if (mainJarPath == null ||
   821         if (mainJarPath == null ||
   818             input == null ) {
   822             input == null ) {
   819             return null;
   823             return null;
   820         } 
   824         }
   821             
   825 
   822         JarFile jf;
   826         JarFile jf;
   823         try {
   827         try {
   824             File file = new File(input, mainJarPath);
   828             File file = new File(input, mainJarPath);
   825             if (!file.exists()) {
   829             if (!file.exists()) {
   826                 return null;
   830                 return null;