setup_gjf.sh: Add support for multiple version

We are in process of upgrading to new google-java-format version. To
simplify upgrade process, allow to set up multiple different versions
of gjf distribution.

To install currently used version 1.3 no parameter is needed

  $ tools/setup-gjf.sh

The resulting script has now version suffix:
  tools/format/google-java-format-1.3

To update to a newer version, version parameter can be passed now:

  $ tools/setup-gjf.sh 1.5

Note, that because of SHA1 check only supported versions can be
currently installed: 1.3 and 1.5.

Change-Id: Id2464cd88291f7f7376df98ca2a396e2458d07a4
This commit is contained in:
David Ostrovsky
2018-01-27 16:11:21 +01:00
committed by David Pursehouse
parent 55304d92b8
commit fa779ef35f

View File

@@ -17,8 +17,20 @@
set -eu
# Keep this version in sync with dev-contributing.txt.
VERSION="1.3"
SHA1="a73cfe6f9af01bd6ff150c0b50c9d620400f784c"
VERSION=${1:-1.3}
case "$VERSION" in
1.3)
SHA1="a73cfe6f9af01bd6ff150c0b50c9d620400f784c"
;;
1.5)
SHA1="b1f79e4d39a3c501f07c0ce7e8b03ac6964ed1f1"
;;
*)
echo "unknown google-java-format version: $VERSION"
exit 1
;;
esac
root="$(git rev-parse --show-toplevel)"
if [[ -z "$root" ]]; then
@@ -33,7 +45,7 @@ name="google-java-format-$VERSION-all-deps.jar"
url="https://github.com/google/google-java-format/releases/download/google-java-format-$VERSION/$name"
"$root/tools/download_file.py" -o "$dir/$name" -u "$url" -v "$SHA1"
launcher="$dir/google-java-format"
launcher="$dir/google-java-format-$VERSION"
cat > "$launcher" <<EOF
#!/bin/bash
#