platform_build_soong/scripts/extract-src-jars.sh
Colin Cross 8eadbf0aaf Fix source jars
Source jars were not working as designed because javac will only
compile files from the -sourcepath if there are references to them
starting from files on the command line.  Switch to extracting
the source jars into a directory and passing a list of the files
to javac.

Test: m checkbuild
Change-Id: I9f7d824f8538d081b2f5ad64ae3cbfd0e96213af
2017-10-26 01:00:46 +00:00

30 lines
603 B
Bash
Executable file

#!/bin/bash -e
# Extracts .java files from source jars in a specified directory and writes out a list of the files
if [ -z "$1" -o -z "$2" ]; then
echo "usage: $0 <output dir> <output file> [<jar> ...]" >&2
exit 1
fi
output_dir=$1
shift
output_file=$1
shift
rm -f $output_file
touch $output_file
for j in "$@"; do
for f in $(zipinfo -1 $j '*.java'); do
echo $output_dir/$f >> $output_file
done
unzip -qn -d $output_dir $j '*.java'
done
duplicates=$(cat $output_file | sort | uniq -d | uniq)
if [ -n "$duplicates" ]; then
echo Duplicate source files:
echo $duplicates
exit 1
fi