src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java
branchJDK-8200758-branch
changeset 57314 23da9e6f446f
parent 57291 f2d429260ad4
child 57316 2891b3ae222d
equal deleted inserted replaced
57307:4948a1944cf9 57314:23da9e6f446f
   165                         return s;
   165                         return s;
   166                     },
   166                     },
   167                     (s, p) -> s
   167                     (s, p) -> s
   168             );
   168             );
   169 
   169 
       
   170     static final StandardBundlerParam<File> PREDEFINED_RUNTIME_IMAGE =
       
   171             new StandardBundlerParam<>(
       
   172                     Arguments.CLIOptions.PREDEFINED_RUNTIME_IMAGE.getId(),
       
   173                     File.class,
       
   174                     params -> null,
       
   175                     (s, p) -> new File(s)
       
   176             );
       
   177 
   170     static final StandardBundlerParam<String> APP_NAME =
   178     static final StandardBundlerParam<String> APP_NAME =
   171             new StandardBundlerParam<>(
   179             new StandardBundlerParam<>(
   172                     Arguments.CLIOptions.NAME.getId(),
   180                     Arguments.CLIOptions.NAME.getId(),
   173                     String.class,
   181                     String.class,
   174                     params -> {
   182                     params -> {
   175                         String s = MAIN_CLASS.fetchFrom(params);
   183                         String s = MAIN_CLASS.fetchFrom(params);
   176                         if (s == null) return null;
   184                         if (s != null) {
   177 
   185                             int idx = s.lastIndexOf(".");
   178                         int idx = s.lastIndexOf(".");
   186                             if (idx >= 0) {
   179                         if (idx >= 0) {
   187                                 return s.substring(idx+1);
   180                             return s.substring(idx+1);
   188                             }
   181                         }
   189                             return s;
   182                         return s;
   190                         } else if (isRuntimeInstaller(params)) {
       
   191                             File f = PREDEFINED_RUNTIME_IMAGE.fetchFrom(params);
       
   192                             if (f != null) {
       
   193                                 return f.getName();
       
   194                             }
       
   195                         }
       
   196                         return null;
   183                     },
   197                     },
   184                     (s, p) -> s
   198                     (s, p) -> s
   185             );
   199             );
   186 
   200 
   187     static final StandardBundlerParam<File> ICON =
   201     static final StandardBundlerParam<File> ICON =
   337     );
   351     );
   338 
   352 
   339     static final StandardBundlerParam<File> PREDEFINED_APP_IMAGE =
   353     static final StandardBundlerParam<File> PREDEFINED_APP_IMAGE =
   340             new StandardBundlerParam<>(
   354             new StandardBundlerParam<>(
   341             Arguments.CLIOptions.PREDEFINED_APP_IMAGE.getId(),
   355             Arguments.CLIOptions.PREDEFINED_APP_IMAGE.getId(),
   342             File.class,
       
   343             params -> null,
       
   344             (s, p) -> new File(s));
       
   345 
       
   346     static final StandardBundlerParam<File> PREDEFINED_RUNTIME_IMAGE =
       
   347             new StandardBundlerParam<>(
       
   348             Arguments.CLIOptions.PREDEFINED_RUNTIME_IMAGE.getId(),
       
   349             File.class,
   356             File.class,
   350             params -> null,
   357             params -> null,
   351             (s, p) -> new File(s));
   358             (s, p) -> new File(s));
   352 
   359 
   353     @SuppressWarnings("unchecked")
   360     @SuppressWarnings("unchecked")
   716                      new LinkedHashSet<>(Collections.singletonList(
   723                      new LinkedHashSet<>(Collections.singletonList(
   717                      mainJarFile)));
   724                      mainJarFile)));
   718             }
   725             }
   719             mainJarFile = new File(mainJarValue);
   726             mainJarFile = new File(mainJarValue);
   720             if (mainJarFile.exists()) {
   727             if (mainJarFile.exists()) {
   721                 // absolute path for main-jar may fail is only legal if
   728                 // absolute path for main-jar may fail is not legal
   722                 // path is within the appResourceRoot directory
   729                 // below contains explicit error message.
   723                 try {
       
   724                     return new RelativeFileSet(appResourcesRoot,
       
   725                          new LinkedHashSet<>(Collections.singletonList(
       
   726                          mainJarFile)));
       
   727                 } catch (Exception e) {
       
   728                     // if not within, RelativeFileSet constructor throws a
       
   729                     // RuntimeException, but the IllegalArgumentException
       
   730                     // below contains a more explicit error message.
       
   731                 }
       
   732             } else {
   730             } else {
   733                 List<Path> modulePath = MODULE_PATH.fetchFrom(params);
   731                 List<Path> modulePath = MODULE_PATH.fetchFrom(params);
   734                 modulePath.removeAll(getDefaultModulePath());
   732                 modulePath.removeAll(getDefaultModulePath());
   735                 if (!modulePath.isEmpty()) {
   733                 if (!modulePath.isEmpty()) {
   736                     Path modularJarPath = JLinkBundlerHelper.findPathOfModule(
   734                     Path modularJarPath = JLinkBundlerHelper.findPathOfModule(