69 String msg = new Formatter().format(format, args).toString(); 70 try { 71 T t = type.getConstructor(String.class).newInstance(msg); 72 throw t; 73 } catch (InstantiationException | 74 InvocationTargetException | 75 NoSuchMethodException | 76 IllegalAccessException e) { 77 throw new InternalError("Unable to create an instance of " + type, e); 78 } 79 } 80 81 private static final TaskHelper taskHelper 82 = new TaskHelper(JLINK_BUNDLE); 83 84 private static final Option<?>[] recognizedOptions = { 85 new Option<JlinkTask>(false, (task, opt, arg) -> { 86 task.options.help = true; 87 }, "--help", "-h"), 88 new Option<JlinkTask>(true, (task, opt, arg) -> { 89 String[] dirs = arg.split(File.pathSeparator); 90 int i = 0; 91 Arrays.stream(dirs) 92 .map(Paths::get) 93 .forEach(task.options.modulePath::add); 94 }, "--module-path", "-p"), 95 new Option<JlinkTask>(true, (task, opt, arg) -> { 96 for (String mn : arg.split(",")) { 97 if (mn.isEmpty()) { 98 throw taskHelper.newBadArgs("err.mods.must.be.specified", 99 "--limit-modules"); 100 } 101 task.options.limitMods.add(mn); 102 } 103 }, "--limit-modules"), 104 new Option<JlinkTask>(true, (task, opt, arg) -> { 105 for (String mn : arg.split(",")) { 106 if (mn.isEmpty()) { 107 throw taskHelper.newBadArgs("err.mods.must.be.specified", 108 "--add-modules"); 109 } 110 task.options.addMods.add(mn); 111 } 112 }, "--add-modules"), 113 new Option<JlinkTask>(true, (task, opt, arg) -> { 114 Path path = Paths.get(arg); 115 task.options.output = path; | 69 String msg = new Formatter().format(format, args).toString(); 70 try { 71 T t = type.getConstructor(String.class).newInstance(msg); 72 throw t; 73 } catch (InstantiationException | 74 InvocationTargetException | 75 NoSuchMethodException | 76 IllegalAccessException e) { 77 throw new InternalError("Unable to create an instance of " + type, e); 78 } 79 } 80 81 private static final TaskHelper taskHelper 82 = new TaskHelper(JLINK_BUNDLE); 83 84 private static final Option<?>[] recognizedOptions = { 85 new Option<JlinkTask>(false, (task, opt, arg) -> { 86 task.options.help = true; 87 }, "--help", "-h"), 88 new Option<JlinkTask>(true, (task, opt, arg) -> { 89 // if used multiple times, the last one wins! 90 // So, clear previous values, if any. 91 task.options.modulePath.clear(); 92 String[] dirs = arg.split(File.pathSeparator); 93 int i = 0; 94 Arrays.stream(dirs) 95 .map(Paths::get) 96 .forEach(task.options.modulePath::add); 97 }, "--module-path", "-p"), 98 new Option<JlinkTask>(true, (task, opt, arg) -> { 99 // if used multiple times, the last one wins! 100 // So, clear previous values, if any. 101 task.options.limitMods.clear(); 102 for (String mn : arg.split(",")) { 103 if (mn.isEmpty()) { 104 throw taskHelper.newBadArgs("err.mods.must.be.specified", 105 "--limit-modules"); 106 } 107 task.options.limitMods.add(mn); 108 } 109 }, "--limit-modules"), 110 new Option<JlinkTask>(true, (task, opt, arg) -> { 111 for (String mn : arg.split(",")) { 112 if (mn.isEmpty()) { 113 throw taskHelper.newBadArgs("err.mods.must.be.specified", 114 "--add-modules"); 115 } 116 task.options.addMods.add(mn); 117 } 118 }, "--add-modules"), 119 new Option<JlinkTask>(true, (task, opt, arg) -> { 120 Path path = Paths.get(arg); 121 task.options.output = path; |