summaryrefslogtreecommitdiff
path: root/scripts/jars-to-module-info-java.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/jars-to-module-info-java.sh')
-rwxr-xr-xscripts/jars-to-module-info-java.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/scripts/jars-to-module-info-java.sh b/scripts/jars-to-module-info-java.sh
new file mode 100755
index 000000000..44be54949
--- /dev/null
+++ b/scripts/jars-to-module-info-java.sh
@@ -0,0 +1,20 @@
+#!/bin/bash -e
+
+# Extracts the Java package names of all classes in the .jar files and writes a module-info.java
+# file to stdout that exports all of those packages.
+
+if [ -z "$1" ]; then
+ echo "usage: $0 <module name> <jar1> [<jar2> ...]" >&2
+ exit 1
+fi
+
+module_name=$1
+shift
+
+echo "module ${module_name} {"
+for j in "$@"; do zipinfo -1 $j ; done \
+ | grep -E '/[^/]*\.class$' \
+ | sed 's|\(.*\)/[^/]*\.class$| exports \1;|g' \
+ | sed 's|/|.|g' \
+ | sort -u
+echo "}"