@@ -7,16 +7,17 @@ def extract_classes(f):
7
7
result = set ()
8
8
for line in lines :
9
9
v = line .decode ('utf-8' ).strip ()
10
- if v .endswith ('.class' ):
10
+ if v .endswith ('.class' ) and not v . endswith ( 'module-info.class' ) :
11
11
result .add (v )
12
12
return result
13
13
14
14
print ('Reading JAR files... ' , end = '' , flush = True )
15
15
paths = []
16
- for root , dirs , files in os .walk ("." ):
16
+ for root , dirs , files in os .walk ('.' ):
17
17
for name in files :
18
18
if not name .lower ().endswith ('.jar' ): continue
19
19
paths .append (os .path .join (root , name ))
20
+ paths .sort ()
20
21
21
22
classes = {}
22
23
count = 0
@@ -25,18 +26,22 @@ def extract_classes(f):
25
26
count += 1
26
27
classes [path ] = extract_classes (path )
27
28
print ('\b ' * len (perc ), end = '' )
28
- perc = str (round (100 * count / len (paths ))) + '% '
29
+ perc = str (round (100 * count / len (paths ))) + '% '
29
30
print (perc , end = '' , flush = True )
30
31
31
- exceptions = [ 'module-info.class' ]
32
- print ('Scanning for duplicate classes..' )
33
- for jar1 in classes :
34
- for jar2 in classes :
35
- if jar1 == jar2 : continue
36
- dups = classes [ jar1 ]. intersection ( classes [ jar2 ])
37
- for exc in exceptions :
38
- if exc in dups : dups . remove ( exc )
32
+ print ()
33
+ print ('Scanning for duplicate classes... ' )
34
+ for i1 in range ( len ( paths )) :
35
+ p1 = paths [ i1 ]
36
+ duplist = []
37
+ for i2 in range ( i1 + 1 , len ( paths )):
38
+ p2 = paths [ i2 ]
39
+ dups = classes [ p1 ]. intersection ( classes [ p2 ] )
39
40
if len (dups ) > 0 :
40
- print (f'==> { jar1 } and { jar2 } have duplicates! E.g. { next (iter (dups ))} ' )
41
+ duplist .append (f'==> { p2 } (e.g. { next (iter (dups ))} )' )
42
+ if len (duplist ) > 0 :
43
+ print (p1 )
44
+ for line in duplist :
45
+ print (line )
41
46
42
47
print ('Done!' )
0 commit comments