postprocessing_python.sh 1.2 KB

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