postprocessing_java.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. set -eu
  3. # Performs Maps-specific post-processing on a .tar.gz archive produced by rule
  4. # java_gapic_assembly_gradle_pkg
  5. # Add gradle publish plugin
  6. #
  7. # Arguments:
  8. # postprocess_dir: The directory that contains the Java files to postprocess.
  9. add_gradle_publish() {
  10. postprocess_dir="${1}"
  11. cat >> "${postprocess_dir}/build.gradle" <<EOF
  12. apply from: "./publish.gradle"
  13. EOF
  14. echo "INFO: Added gradle publish plugin."
  15. }
  16. # Change group name from cloud
  17. #
  18. # Arguments:
  19. # postprocess_dir: The directory that contains the Java files to postprocess.
  20. change_group() {
  21. postprocess_dir="${1}"
  22. for f in $(find "${postprocess_dir}" -name "*.gradle" -type f); do
  23. sed -e "s/= 'com\.google\.cloud'/= 'com\.google\.maps'/g" "${f}" > "${f}.new" && mv "${f}.new" "${f}"
  24. sed -e "s/= 'com\.google\.api\.grpc'/= 'com\.google\.maps'/g" "${f}" > "${f}.new" && mv "${f}.new" "${f}"
  25. done
  26. }
  27. # Main entry point
  28. #
  29. # Arguments:
  30. # postprocess_dir: The directory that contains the Java files to postprocess.
  31. main() {
  32. postprocess_dir="$1"
  33. if [ "${postprocess_dir}" = "" ]; then
  34. echo "postprocess_dir is required"
  35. exit 1
  36. fi
  37. add_gradle_publish "${postprocess_dir}"
  38. change_group "${postprocess_dir}"
  39. }
  40. main "$@"