-
-
Notifications
You must be signed in to change notification settings - Fork 452
/
Copy pathupdate-gradle.sh
executable file
·51 lines (42 loc) · 1.2 KB
/
update-gradle.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
set -euo pipefail
cd $(dirname "$0")/../
if [[ -n ${CI+x} ]]; then
export JAVA_HOME=$JAVA_HOME_17_X64
fi
case $1 in
get-version)
# `./gradlew` shows some info on the first run, breaking the parsing in the next step.
# Therefore, we run it once without checking any output.
./gradlew --version >/dev/null
version="$(./gradlew --version | sed -E -n 's/.*Gradle +([0-9.]+).*/\1/p')"
# Add trailing ".0" - gradlew outputs '7.1' instead of '7.1.0'
if [[ "$version" =~ ^[0-9]\.[0-9]$ ]]; then
version="$version.0"
fi
echo "v$version"
;;
get-repo)
echo "https://github.com/gradle/gradle.git"
;;
set-version)
version=$2
# Remove leading "v"
if [[ "$version" == v* ]]; then
version="${version:1}"
fi
# Remove trailing ".0" - gradlew expects '7.1' instead of '7.1.0'
if [[ "$version" == *".0" ]]; then
version="${version:0:${#version}-2}"
fi
echo "Setting gradle version to '$version'"
# This sets version to gradle-wrapper.properties.
./gradlew wrapper --gradle-version "$version"
# Verify it works.
./gradlew --version
;;
*)
echo "Unknown argument $1"
exit 1
;;
esac