Skip to content

Commit 22a568f

Browse files
committed
class-version.sh: make detection more robust
If a class lives in META-INF/versions/ we can ignore it because it's specially targeting a different version of Java than other classes. If a module-info.class is present, we can ignore it because it must target Java 9 or newer even if the other classes target an earlier version.
1 parent 7db8ec0 commit 22a568f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

class-version.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ class_version() {
4949
}
5050

5151
first_class() {
52-
jar tf "$1" | grep '\.class$' | head -n 1
52+
jar tf "$1" |
53+
grep '\.class$' |
54+
grep -v '^META-INF/' |
55+
grep -v 'module-info\.class' |
56+
head -n 1
5357
}
5458

5559
for file in "$@"

0 commit comments

Comments
 (0)