@@ -4,6 +4,7 @@ set -eo pipefail
44utilities_script_dir=$( dirname " $( realpath " ${BASH_SOURCE[0]} " ) " )
55# The $HOME variable is always set in the OS env as per POSIX specification.
66GAPIC_GENERATOR_LOCATION=" ${HOME} /.library_generation/gapic-generator-java.jar"
7+ JAVA_FORMATTER_LOCATION=" ${HOME} /.library_generation/google-java-format.jar"
78
89# Utility functions used in `generate_library.sh` and showcase generation.
910extract_folder_name () {
@@ -137,10 +138,11 @@ get_protoc_version() {
137138# and "grpc_path" to DOCKER_PROTOC_PATH and DOCKER_GRPC_PATH respectively (no
138139# download), since the docker image will have downloaded these tools beforehand.
139140#
140- # For the case of gapic-generator-java, no env var will be exported for the
141- # upstream flow. Instead, the jar must be located in the well-known location
142- # (${HOME}/.library_generation/gapic-generator-java.jar). More information in
143- # `library_generation/DEVELOPMENT.md`
141+ # For the case of generator and formatter, no env var will be exported for the
142+ # upstream flow.
143+ # Instead, the jar must be located in the well-known location
144+ # (${HOME}/.library_generation/).
145+ # More information in `library_generation/DEVELOPMENT.md`.
144146download_tools () {
145147 local protoc_version=$1
146148 local grpc_version=$2
@@ -166,18 +168,11 @@ download_tools() {
166168 export grpc_path=$( download_grpc_plugin " ${grpc_version} " " ${os_architecture} " )
167169 fi
168170
169- # Here we check whether the jar is stored in the expected location.
170- # The docker image will prepare the jar in this location. Developers must
171- # prepare their environment by creating
172- # $HOME/.library_generation/gapic_generator_java.jar
173- # This check is meant to ensure integrity of the downstream workflow. (i.e.
174- # ensure the generator wrapper succeeds)
175- if [[ ! -f " ${GAPIC_GENERATOR_LOCATION} " ]]; then
176- >&2 echo " File ${GAPIC_GENERATOR_LOCATION} not found in the "
177- >&2 echo " filesystem. Please configure your environment and store the "
178- >&2 echo " generator jar in this location"
179- exit 1
180- fi
171+ # Here we check whether required tools is stored in the expected location.
172+ # The docker image will prepare jar files in this location.
173+ # This check is meant to ensure integrity of the downstream workflow.
174+ error_if_not_exists " ${GAPIC_GENERATOR_LOCATION} "
175+ error_if_not_exists " ${JAVA_FORMATTER_LOCATION} "
181176 popd
182177}
183178
@@ -380,3 +375,17 @@ download_googleapis_files_and_folders() {
380375get_gapic_generator_location () {
381376 echo " ${GAPIC_GENERATOR_LOCATION} "
382377}
378+
379+ get_java_formatter_location () {
380+ echo " ${JAVA_FORMATTER_LOCATION} "
381+ }
382+
383+ error_if_not_exists () {
384+ local required_tool=$1
385+ if [[ ! -f " ${required_tool} " ]]; then
386+ >&2 echo " File ${required_tool} not found in the filesystem. "
387+ >&2 echo " Please configure your environment and store the "
388+ >&2 echo " required tools in this location."
389+ exit 1
390+ fi
391+ }
0 commit comments