@@ -4,6 +4,7 @@ set -eo pipefail
4
4
utilities_script_dir=$( dirname " $( realpath " ${BASH_SOURCE[0]} " ) " )
5
5
# The $HOME variable is always set in the OS env as per POSIX specification.
6
6
GAPIC_GENERATOR_LOCATION=" ${HOME} /.library_generation/gapic-generator-java.jar"
7
+ JAVA_FORMATTER_LOCATION=" ${HOME} /.library_generation/google-java-format.jar"
7
8
8
9
# Utility functions used in `generate_library.sh` and showcase generation.
9
10
extract_folder_name () {
@@ -137,10 +138,11 @@ get_protoc_version() {
137
138
# and "grpc_path" to DOCKER_PROTOC_PATH and DOCKER_GRPC_PATH respectively (no
138
139
# download), since the docker image will have downloaded these tools beforehand.
139
140
#
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`.
144
146
download_tools () {
145
147
local protoc_version=$1
146
148
local grpc_version=$2
@@ -166,18 +168,11 @@ download_tools() {
166
168
export grpc_path=$( download_grpc_plugin " ${grpc_version} " " ${os_architecture} " )
167
169
fi
168
170
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} "
181
176
popd
182
177
}
183
178
@@ -380,3 +375,17 @@ download_googleapis_files_and_folders() {
380
375
get_gapic_generator_location () {
381
376
echo " ${GAPIC_GENERATOR_LOCATION} "
382
377
}
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