src/jdk.jpackage/share/classes/jdk/jpackage/internal/JLinkBundlerHelper.java
branchJDK-8200758-branch
changeset 57391 970f28090a06
parent 57389 cce526c681dc
child 57392 46d4b0aa4542
equal deleted inserted replaced
57390:1cb722a11ead 57391:970f28090a06
    71     static final ToolProvider JLINK_TOOL =
    71     static final ToolProvider JLINK_TOOL =
    72             ToolProvider.findFirst("jlink").orElseThrow();
    72             ToolProvider.findFirst("jlink").orElseThrow();
    73 
    73 
    74     private JLinkBundlerHelper() {}
    74     private JLinkBundlerHelper() {}
    75 
    75 
    76     @SuppressWarnings("unchecked")
       
    77     static final BundlerParamInfo<Integer> DEBUG =
       
    78             new StandardBundlerParam<>(
       
    79                     "-J-Xdebug",
       
    80                     Integer.class,
       
    81                     p -> null,
       
    82                     (s, p) -> {
       
    83                         return Integer.valueOf(s);
       
    84                     });
       
    85 
       
    86     static String listOfPathToString(List<Path> value) {
    76     static String listOfPathToString(List<Path> value) {
    87         String result = "";
    77         String result = "";
    88 
    78 
    89         for (Path path : value) {
    79         for (Path path : value) {
    90             if (result.length() > 0) {
    80             if (result.length() > 0) {
   193         Set<String> addModules =
   183         Set<String> addModules =
   194                 StandardBundlerParam.ADD_MODULES.fetchFrom(params);
   184                 StandardBundlerParam.ADD_MODULES.fetchFrom(params);
   195         Set<String> limitModules =
   185         Set<String> limitModules =
   196                 StandardBundlerParam.LIMIT_MODULES.fetchFrom(params);
   186                 StandardBundlerParam.LIMIT_MODULES.fetchFrom(params);
   197         Path outputDir = imageBuilder.getRoot();
   187         Path outputDir = imageBuilder.getRoot();
   198         String excludeFileList = imageBuilder.getExcludeFileList();
       
   199         File mainJar = getMainJar(params);
   188         File mainJar = getMainJar(params);
   200         ModFile.ModType mainJarType = ModFile.ModType.Unknown;
   189         ModFile.ModType mainJarType = ModFile.ModType.Unknown;
   201 
   190 
   202         if (mainJar != null) {
   191         if (mainJar != null) {
   203             mainJarType = new ModFile(mainJar).getModType();
   192             mainJarType = new ModFile(mainJar).getModType();
   227 
   216 
   228         if (mainModule != null) {
   217         if (mainModule != null) {
   229             validModules.add(mainModule);
   218             validModules.add(mainModule);
   230         }
   219         }
   231 
   220 
   232         Log.verbose(MessageFormat.format(
       
   233                 I18N.getString("message.modules"), validModules.toString()));
       
   234 
       
   235         runJLink(outputDir, modulePath, validModules, limitModules,
   221         runJLink(outputDir, modulePath, validModules, limitModules,
   236                 excludeFileList, new HashMap<String,String>(), bindServices);
   222                 new HashMap<String,String>(), bindServices);
   237 
   223 
   238         imageBuilder.prepareApplicationFiles();
   224         imageBuilder.prepareApplicationFiles();
   239     }
   225     }
   240 
   226 
   241 
   227 
   385             return result;
   371             return result;
   386         }
   372         }
   387     }
   373     }
   388 
   374 
   389     private static void runJLink(Path output, List<Path> modulePath,
   375     private static void runJLink(Path output, List<Path> modulePath,
   390             Set<String> modules, Set<String> limitModules, String excludes,
   376             Set<String> modules, Set<String> limitModules,
   391             HashMap<String, String> user, boolean bindServices)
   377             HashMap<String, String> user, boolean bindServices)
   392             throws IOException {
   378             throws IOException {
   393 
   379 
   394         // This is just to ensure jlink is given a non-existant directory
   380         // This is just to ensure jlink is given a non-existant directory
   395         // The passed in output path should be non-existant or empty directory
   381         // The passed in output path should be non-existant or empty directory
   407             args.add(getStringList(modules));
   393             args.add(getStringList(modules));
   408         }
   394         }
   409         if (limitModules != null && !limitModules.isEmpty()) {
   395         if (limitModules != null && !limitModules.isEmpty()) {
   410             args.add("--limit-modules");
   396             args.add("--limit-modules");
   411             args.add(getStringList(limitModules));
   397             args.add(getStringList(limitModules));
   412         }
       
   413         if (excludes != null) {
       
   414             args.add("--exclude-files");
       
   415             args.add(excludes);
       
   416         }
   398         }
   417         if (user != null && !user.isEmpty()) {
   399         if (user != null && !user.isEmpty()) {
   418             for (Map.Entry<String, String> entry : user.entrySet()) {
   400             for (Map.Entry<String, String> entry : user.entrySet()) {
   419                 args.add(entry.getKey());
   401                 args.add(entry.getKey());
   420                 args.add(entry.getValue());
   402                 args.add(entry.getValue());