|
8 | 8 | # $ show-duplicate-java-classes path/to/lib_dir1 /path/to/lib_dir2 |
9 | 9 | # $ show-duplicate-java-classes -c path/to/class_dir1 -c /path/to/class_dir2 |
10 | 10 | # $ show-duplicate-java-classes -c path/to/class_dir1 path/to/lib_dir1 |
11 | | -# $ show-duplicate-java-classes -L path/to/lib_dir1 # search jars in the sub-directories of lib dir |
| 11 | +# $ show-duplicate-java-classes -L path/to/lib_dir1 # search jars in the subdirectories of lib dir |
12 | 12 | # $ show-duplicate-java-classes -J path/to/lib_dir1 # search jars in the jar file |
13 | 13 | # |
14 | 14 | # @online-doc https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/java.md#-show-duplicate-java-classes |
@@ -297,6 +297,9 @@ def print_duplicate_classes_info(class_paths_to_duplicate_classes, class_path_to |
297 | 297 |
|
298 | 298 |
|
299 | 299 | def print_class_paths_info(class_path_to_classes): |
| 300 | + if not class_path_to_classes: |
| 301 | + return |
| 302 | + |
300 | 303 | max_idx_str_len = str_len(len(class_path_to_classes)) |
301 | 304 | max_classes_count_str_len = str_len(max(len(classes) for classes in class_path_to_classes.values())) |
302 | 305 |
|
@@ -329,14 +332,24 @@ def main(): |
329 | 332 | action='append', help='add class dir') |
330 | 333 | option_parser.add_option('-R', '--no-find-progress', dest='show_responsive', default=True, |
331 | 334 | action='store_false', help='do not display responsive find progress') |
| 335 | + |
332 | 336 | options, lib_dirs = option_parser.parse_args() |
| 337 | + class_dirs = options.class_dirs |
| 338 | + if not lib_dirs and not class_dirs: |
| 339 | + lib_dirs = ['.'] |
333 | 340 | global __show_responsive |
334 | 341 | __show_responsive = options.show_responsive |
335 | | - if not options.class_dirs and not lib_dirs: |
336 | | - lib_dirs = ['.'] |
337 | 342 |
|
338 | 343 | jar_files = list_jar_file_under_lib_dirs(lib_dirs, recursive=options.recursive_lib) |
339 | | - class_path_to_classes = collect_class_path_to_classes(options.class_dirs, jar_files, options.recursive_jar) |
| 344 | + if not jar_files and not class_dirs: |
| 345 | + clear_responsive_message() |
| 346 | + print('search no jar files under lib dirs, and class dirs is absent.') |
| 347 | + return 0 |
| 348 | + class_path_to_classes = collect_class_path_to_classes(class_dirs, jar_files, options.recursive_jar) |
| 349 | + if all(not classes for classes in class_path_to_classes.values()): |
| 350 | + clear_responsive_message() |
| 351 | + print('find no class files in jar files or class dirs.') |
| 352 | + return 0 |
340 | 353 |
|
341 | 354 | print_responsive_message('find duplicate classes...') |
342 | 355 | class_to_class_paths = invert_as_class_to_class_paths(class_path_to_classes) |
|
0 commit comments