extract-srcjars.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash -e
  2. # Copyright 2017 Google Inc. All rights reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # Extracts .java files from source jars in a specified directory and writes out a list of the files
  16. if [ -z "$1" -o -z "$2" ]; then
  17. echo "usage: $0 <output dir> <output file> [<jar> ...]" >&2
  18. exit 1
  19. fi
  20. output_dir=$1
  21. shift
  22. output_file=$1
  23. shift
  24. rm -f $output_file
  25. touch $output_file
  26. for j in "$@"; do
  27. for f in $(zipinfo -1 $j '*.java'); do
  28. echo $output_dir/$f >> $output_file
  29. done
  30. unzip -qn -d $output_dir $j '*.java'
  31. done
  32. duplicates=$(cat $output_file | sort | uniq -d | uniq)
  33. if [ -n "$duplicates" ]; then
  34. echo Duplicate source files:
  35. echo $duplicates
  36. exit 1
  37. fi