-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsetup_gradle.sh
executable file
·39 lines (32 loc) · 1.1 KB
/
setup_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
#!/bin/sh
set -eu
ROOT_DIR=$(dirname $(realpath $0))
. ${ROOT_DIR}/config.sh
## NOTES:
## On alpine, gradle version should be >= 8.8
## https://github.com/gradle/gradle/issues/24875
## On android, alpine openjdk > 17 may not work
setup() {
PREFIX_DIR="$1"
msg "Setting up gradle ..."
check_tools java
GRADLE_URL=https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-${GRADLE_VARIANT}.zip
# GRADLE_URL=https://mirrors.cloud.tencent.com/gradle/gradle-${GRADLE_VERSION}-${GRADLE_VARIANT}.zip
# GRADLE_URL=https://mirrors.huaweicloud.com/gradle/gradle-${GRADLE_VERSION}-${GRADLE_VARIANT}.zip
GRADLE_ROOT=${PREFIX_DIR}/gradle-${GRADLE_VERSION}
gradle_archive="${TMPDIR}/gradle-${GRADLE_VERSION}.zip"
if ! test -d "${GRADLE_ROOT}"; then
if ! test -f "${gradle_archive}"; then
${dl_cmd} "${GRADLE_URL}" >"${gradle_archive}.tmp"
mv "${gradle_archive}.tmp" "${gradle_archive}"
fi
unzip -q -d "$(dirname ${GRADLE_ROOT})" "${gradle_archive}"
fi
msg "Checking gradle ..."
"${GRADLE_ROOT}/bin/gradle" --version
}
if test $# -gt 0; then
setup "$1"
else
msg "Usage: $PROGRAM [PREFIX_DIR]"
fi