JAL-3130 incorporating feature/JAL-3063jaxbNoCastor and new script utils/jdeps_jlink_...
[jalview.git] / utils / jdeps_jlink_all.sh
diff --git a/utils/jdeps_jlink_all.sh b/utils/jdeps_jlink_all.sh
new file mode 100755 (executable)
index 0000000..394e8b5
--- /dev/null
@@ -0,0 +1,23 @@
+#/usr/bin/env bash
+
+# be in the jalview top level dir.
+# lib -- contains usual jalview jar files
+# j11lib -- contains extra jar files needed in classpath for Java 11
+# j11mod -- contains java11 style modules to be put into the JRE (not needed at runtime)
+#
+# j11jre -- dir containing JRE environments for jalview
+#
+# creates file modules.new which is comma-separated list of modules needed, can be used like this in jlink argument
+# and a java 11 JRE in j11jre/jre-new
+
+( for x in lib/*.jar j11lib/*.jar j11mod/*.jar dist/jalview.jar; do echo $x >&2; jdeps --list-deps --module-path j11mod $x | grep -v Warning: | grep -v "JDK removed" | sed -e 's/^ *//;s/\/.*//;s/$/,/;'; done ) | sort -u | perl -p -e 'chomp;' | sed -e 's/,$//;' > modules.new
+
+if [ x$JAVA_HOME != x ]; then
+  jlink --no-header-files --no-man-pages --strip-debug --module-path "$JAVA_HOME/jmods:j11mod" --add-modules `cat modules.new` --compress=2 --output j11jre/jre-new
+else
+  jlink --no-header-files --no-man-pages --strip-debug --module-path "j11mod" --add-modules `cat modules.new` --compress=2 --output j11jre/jre-new
+fi
+
+
+# or if you're in a hurry for a one-liner...
+#jlink --no-header-files --no-man-pages --strip-debug --module-path "$JAVA_HOME/jmods:j11mod" --add-modules ` ( for x in lib/*.jar j11lib/*.jar j11mod/*.jar dist/jalview.jar; do echo $x >&2; jdeps --list-deps --module-path j11mod $x | grep -v "Warning:" | grep -v "JDK removed" | sed -e 's/^ *//;s/\/.*//;s/$/,/;'; done ) | sort -u | perl -p -e 'chomp;' | sed -e 's/,$//;' ` --compress=2 --output j11jre/jre-new