142 return true; |
142 return true; |
143 } |
143 } |
144 } |
144 } |
145 |
145 |
146 static Option[] recognizedOptions = { |
146 static Option[] recognizedOptions = { |
147 new Option(false, "-h", "-?", "-help") { |
147 new Option(false, "-h", "-?", "-help", "--help") { |
148 void process(JdepsTask task, String opt, String arg) { |
148 void process(JdepsTask task, String opt, String arg) { |
149 task.options.help = true; |
149 task.options.help = true; |
150 } |
150 } |
151 }, |
151 }, |
152 new Option(true, "-dotoutput") { |
152 new Option(true, "-dotoutput") { |
193 new Option(false, "-apionly") { |
193 new Option(false, "-apionly") { |
194 void process(JdepsTask task, String opt, String arg) { |
194 void process(JdepsTask task, String opt, String arg) { |
195 task.options.apiOnly = true; |
195 task.options.apiOnly = true; |
196 } |
196 } |
197 }, |
197 }, |
198 new Option(true, "-check") { |
198 new Option(true, "--check") { |
199 void process(JdepsTask task, String opt, String arg) throws BadArgs { |
199 void process(JdepsTask task, String opt, String arg) throws BadArgs { |
200 Set<String> mods = Set.of(arg.split(",")); |
200 Set<String> mods = Set.of(arg.split(",")); |
201 task.options.checkModuleDeps = mods; |
201 task.options.checkModuleDeps = mods; |
202 task.options.addmods.addAll(mods); |
202 task.options.addmods.addAll(mods); |
203 } |
203 } |
204 }, |
204 }, |
205 new Option(true, "-genmoduleinfo") { |
205 new Option(true, "--gen-module-info") { |
206 void process(JdepsTask task, String opt, String arg) throws BadArgs { |
206 void process(JdepsTask task, String opt, String arg) throws BadArgs { |
207 Path p = Paths.get(arg); |
207 Path p = Paths.get(arg); |
208 if (Files.exists(p) && (!Files.isDirectory(p) || !Files.isWritable(p))) { |
208 if (Files.exists(p) && (!Files.isDirectory(p) || !Files.isWritable(p))) { |
209 throw new BadArgs("err.invalid.path", arg); |
209 throw new BadArgs("err.invalid.path", arg); |
210 } |
210 } |
220 } |
220 } |
221 } |
221 } |
222 }, |
222 }, |
223 |
223 |
224 // ---- paths option ---- |
224 // ---- paths option ---- |
225 new Option(true, "-cp", "-classpath") { |
225 new Option(true, "-cp", "-classpath", "--class-path") { |
226 void process(JdepsTask task, String opt, String arg) { |
226 void process(JdepsTask task, String opt, String arg) { |
227 task.options.classpath = arg; |
227 task.options.classpath = arg; |
228 } |
228 } |
229 }, |
229 }, |
230 new Option(true, "-mp", "-modulepath") { |
230 new Option(true, "--module-path") { |
231 void process(JdepsTask task, String opt, String arg) throws BadArgs { |
231 void process(JdepsTask task, String opt, String arg) throws BadArgs { |
232 task.options.modulePath = arg; |
232 task.options.modulePath = arg; |
233 } |
233 } |
234 }, |
234 }, |
235 new Option(true, "-upgrademodulepath") { |
235 new Option(true, "--upgrade-module-path") { |
236 void process(JdepsTask task, String opt, String arg) throws BadArgs { |
236 void process(JdepsTask task, String opt, String arg) throws BadArgs { |
237 task.options.upgradeModulePath = arg; |
237 task.options.upgradeModulePath = arg; |
238 } |
238 } |
239 }, |
239 }, |
240 new Option(true, "-system") { |
240 new Option(true, "--system") { |
241 void process(JdepsTask task, String opt, String arg) throws BadArgs { |
241 void process(JdepsTask task, String opt, String arg) throws BadArgs { |
242 if (arg.equals("none")) { |
242 if (arg.equals("none")) { |
243 task.options.systemModulePath = null; |
243 task.options.systemModulePath = null; |
244 } else { |
244 } else { |
245 Path path = Paths.get(arg); |
245 Path path = Paths.get(arg); |
248 else |
248 else |
249 throw new BadArgs("err.invalid.path", arg); |
249 throw new BadArgs("err.invalid.path", arg); |
250 } |
250 } |
251 } |
251 } |
252 }, |
252 }, |
253 new Option(true, "-addmods") { |
253 new Option(true, "--add-modules") { |
254 void process(JdepsTask task, String opt, String arg) throws BadArgs { |
254 void process(JdepsTask task, String opt, String arg) throws BadArgs { |
255 Set<String> mods = Set.of(arg.split(",")); |
255 Set<String> mods = Set.of(arg.split(",")); |
256 task.options.addmods.addAll(mods); |
256 task.options.addmods.addAll(mods); |
257 } |
257 } |
258 }, |
258 }, |
259 new Option(true, "-m") { |
259 new Option(true, "-m", "--module") { |
260 void process(JdepsTask task, String opt, String arg) throws BadArgs { |
260 void process(JdepsTask task, String opt, String arg) throws BadArgs { |
261 task.options.rootModule = arg; |
261 task.options.rootModule = arg; |
262 task.options.addmods.add(arg); |
262 task.options.addmods.add(arg); |
263 } |
263 } |
264 }, |
264 }, |
312 task.options.includePattern = Pattern.compile(arg); |
312 task.options.includePattern = Pattern.compile(arg); |
313 } |
313 } |
314 }, |
314 }, |
315 |
315 |
316 // Another alternative to list modules in -addmods option |
316 // Another alternative to list modules in -addmods option |
317 new HiddenOption(true, "-include-system-modules") { |
317 new HiddenOption(true, "--include-system-modules") { |
318 void process(JdepsTask task, String opt, String arg) throws BadArgs { |
318 void process(JdepsTask task, String opt, String arg) throws BadArgs { |
319 task.options.includeSystemModulePattern = Pattern.compile(arg); |
319 task.options.includeSystemModulePattern = Pattern.compile(arg); |
320 } |
320 } |
321 }, |
321 }, |
322 |
322 |
343 task.options.filterSamePackage = true; |
343 task.options.filterSamePackage = true; |
344 task.options.filterSameArchive = true; |
344 task.options.filterSameArchive = true; |
345 } |
345 } |
346 }, |
346 }, |
347 |
347 |
348 new Option(false, "-ct", "-compile-time") { |
348 new Option(false, "--compile-time") { |
349 void process(JdepsTask task, String opt, String arg) { |
349 void process(JdepsTask task, String opt, String arg) { |
350 task.options.compileTimeView = true; |
350 task.options.compileTimeView = true; |
351 task.options.filterSamePackage = true; |
351 task.options.filterSamePackage = true; |
352 task.options.filterSameArchive = true; |
352 task.options.filterSameArchive = true; |
353 task.options.depth = 0; |
353 task.options.depth = 0; |
373 new HiddenOption(false, "-showlabel") { |
373 new HiddenOption(false, "-showlabel") { |
374 void process(JdepsTask task, String opt, String arg) { |
374 void process(JdepsTask task, String opt, String arg) { |
375 task.options.showLabel = true; |
375 task.options.showLabel = true; |
376 } |
376 } |
377 }, |
377 }, |
378 new HiddenOption(false, "-hide-module") { |
378 new HiddenOption(false, "--hide-show-module") { |
379 void process(JdepsTask task, String opt, String arg) { |
379 void process(JdepsTask task, String opt, String arg) { |
380 task.options.showModule = false; |
380 task.options.showModule = false; |
381 } |
381 } |
382 }, |
382 }, |
383 new HiddenOption(true, "-depth") { |
383 new HiddenOption(true, "-depth") { |
462 if (options.showSummary && options.verbose != SUMMARY) { |
462 if (options.showSummary && options.verbose != SUMMARY) { |
463 showHelp(); |
463 showHelp(); |
464 return EXIT_CMDERR; |
464 return EXIT_CMDERR; |
465 } |
465 } |
466 if (options.checkModuleDeps != null && !inputArgs.isEmpty()) { |
466 if (options.checkModuleDeps != null && !inputArgs.isEmpty()) { |
467 reportError("err.invalid.module.option", inputArgs, "-check"); |
467 reportError("err.invalid.module.option", inputArgs, "--check"); |
468 } |
468 } |
469 |
469 |
470 boolean ok = run(); |
470 boolean ok = run(); |
471 return ok ? EXIT_OK : EXIT_ERROR; |
471 return ok ? EXIT_OK : EXIT_ERROR; |
472 } catch (BadArgs|UncheckedBadArgs e) { |
472 } catch (BadArgs|UncheckedBadArgs e) { |
499 Stream.concat(options.addmods.stream(), options.requires.stream()) |
499 Stream.concat(options.addmods.stream(), options.requires.stream()) |
500 .filter(mn -> !config.isValidToken(mn)) |
500 .filter(mn -> !config.isValidToken(mn)) |
501 .forEach(mn -> config.findModule(mn).orElseThrow(() -> |
501 .forEach(mn -> config.findModule(mn).orElseThrow(() -> |
502 new UncheckedBadArgs(new BadArgs("err.module.not.found", mn)))); |
502 new UncheckedBadArgs(new BadArgs("err.module.not.found", mn)))); |
503 |
503 |
504 // -genmoduleinfo |
504 // --gen-module-info |
505 if (options.genModuleInfo != null) { |
505 if (options.genModuleInfo != null) { |
506 return genModuleInfo(config); |
506 return genModuleInfo(config); |
507 } |
507 } |
508 |
508 |
509 // -check |
509 // --check |
510 if (options.checkModuleDeps != null) { |
510 if (options.checkModuleDeps != null) { |
511 return new ModuleAnalyzer(config, log, options.checkModuleDeps).run(); |
511 return new ModuleAnalyzer(config, log, options.checkModuleDeps).run(); |
512 } |
512 } |
513 |
513 |
514 if (options.dotOutputDir != null && |
514 if (options.dotOutputDir != null && |