platform_build_soong/scripts/jars-to-module-info-java.sh
Colin Cross 1369cdb280 Initial support for converting jars to java9 system modules
Adds a java_system_modules module type that (when
EXPERIMENTAL_USE_OPENJDK9 is set to true) converts a list of
java library modules and prebuilt jars into system modules,
and plumbs the system modules through to the javac command
line.

Also exports the location of the system modules to make
variables, as well as the name of the default system module.

Test: TestClasspath in java_test.go, runs automatically as part of the build
Bug: 63986449
Change-Id: I27bd5d2010092422a27b69c91568e49010e02f40
2017-10-16 15:00:02 -07:00

20 lines
477 B
Bash
Executable file

#!/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 "}"