< prev index next >

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java

Print this page
rev 48074 : 8189102: All tools should support -?, -h and --help
Reviewed-by: kvn, jjg, weijun, alanb, rfield, ksrini


  70 import jdk.internal.module.ModulePath;
  71 import jdk.internal.module.ModuleResolution;
  72 
  73 /**
  74  * Implementation for the jlink tool.
  75  *
  76  * ## Should use jdk.joptsimple some day.
  77  */
  78 public class JlinkTask {
  79     static final boolean DEBUG = Boolean.getBoolean("jlink.debug");
  80 
  81     // jlink API ignores by default. Remove when signing is implemented.
  82     static final boolean IGNORE_SIGNING_DEFAULT = true;
  83 
  84     private static final TaskHelper taskHelper
  85             = new TaskHelper(JLINK_BUNDLE);
  86 
  87     private static final Option<?>[] recognizedOptions = {
  88         new Option<JlinkTask>(false, (task, opt, arg) -> {
  89             task.options.help = true;
  90         }, "--help", "-h"),
  91         new Option<JlinkTask>(true, (task, opt, arg) -> {
  92             // if used multiple times, the last one wins!
  93             // So, clear previous values, if any.
  94             task.options.modulePath.clear();
  95             String[] dirs = arg.split(File.pathSeparator);
  96             int i = 0;
  97             Arrays.stream(dirs)
  98                   .map(Paths::get)
  99                   .forEach(task.options.modulePath::add);
 100         }, "--module-path", "-p"),
 101         new Option<JlinkTask>(true, (task, opt, arg) -> {
 102             // if used multiple times, the last one wins!
 103             // So, clear previous values, if any.
 104             task.options.limitMods.clear();
 105             for (String mn : arg.split(",")) {
 106                 if (mn.isEmpty()) {
 107                     throw taskHelper.newBadArgs("err.mods.must.be.specified",
 108                             "--limit-modules");
 109                 }
 110                 task.options.limitMods.add(mn);




  70 import jdk.internal.module.ModulePath;
  71 import jdk.internal.module.ModuleResolution;
  72 
  73 /**
  74  * Implementation for the jlink tool.
  75  *
  76  * ## Should use jdk.joptsimple some day.
  77  */
  78 public class JlinkTask {
  79     static final boolean DEBUG = Boolean.getBoolean("jlink.debug");
  80 
  81     // jlink API ignores by default. Remove when signing is implemented.
  82     static final boolean IGNORE_SIGNING_DEFAULT = true;
  83 
  84     private static final TaskHelper taskHelper
  85             = new TaskHelper(JLINK_BUNDLE);
  86 
  87     private static final Option<?>[] recognizedOptions = {
  88         new Option<JlinkTask>(false, (task, opt, arg) -> {
  89             task.options.help = true;
  90         }, "--help", "-h", "-?"),
  91         new Option<JlinkTask>(true, (task, opt, arg) -> {
  92             // if used multiple times, the last one wins!
  93             // So, clear previous values, if any.
  94             task.options.modulePath.clear();
  95             String[] dirs = arg.split(File.pathSeparator);
  96             int i = 0;
  97             Arrays.stream(dirs)
  98                   .map(Paths::get)
  99                   .forEach(task.options.modulePath::add);
 100         }, "--module-path", "-p"),
 101         new Option<JlinkTask>(true, (task, opt, arg) -> {
 102             // if used multiple times, the last one wins!
 103             // So, clear previous values, if any.
 104             task.options.limitMods.clear();
 105             for (String mn : arg.split(",")) {
 106                 if (mn.isEmpty()) {
 107                     throw taskHelper.newBadArgs("err.mods.must.be.specified",
 108                             "--limit-modules");
 109                 }
 110                 task.options.limitMods.add(mn);


< prev index next >