-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgw
executable file
·79 lines (70 loc) · 1.81 KB
/
gw
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
die() {
echo $@
exit 1
}
usage() {
cat<<EOF
gradlew.sh: builds a Kafka project with gradle.
-C: use git clean -fdqx . to clean before building.
-c: pass this to enable checks such as spotbugs.
-i: pass this to run the install target.
-h: this help message.
-l: pass this to filter gradlew through less
-S [version]: the scala version. For example, 2.12 or 2.13
-t: run tests. Specify this more than once to run more tests.
EOF
}
clean=0
check=0
install=0
use_less=0
scala_version=""
test_level=0
while getopts "CcihlS:t" flag; do
case $flag in
C) clean=1;;
c) check=1;;
i) install=1;;
h) usage; exit 0;;
l) use_less=1;;
S) scala_version="${OPTARG}";;
t) test_level=$(($test_level+1));;
*) echo "getopts error"
echo
usage
exit 1;;
esac
#echo "$flag" $OPTIND $OPTARG
done
shift $(($OPTIND - 1))
EXTRA_ARGS="${@}"
GRADLE_ARGS="jar -x test -x javadoc"
if [[ ${clean} -eq 1 ]]; then
echo "[ running git clean ]"
git clean -fdqx . || die "git clean failed"
fi
if [[ ${check} -eq 1 ]]; then
GRADLE_ARGS="${GRADLE_ARGS} check"
else
GRADLE_ARGS="${GRADLE_ARGS} -x check"
fi
if [[ ${install} -eq 1 ]]; then
GRADLE_ARGS="${GRADLE_ARGS} install"
fi
if [[ $test_level -ge 1 ]]; then
GRADLE_ARGS="${GRADLE_ARGS} :metadata:test :server-common:test :shell:test"
fi
if [[ $test_level -ge 2 ]]; then
die "test level 2 and above are not supported yet."
fi
SCALA_VERSION_ARG=""
if [[ "${scala_version}" != "" ]]; then
SCALA_VERSION_ARG="-PscalaVersion=$scala_version"
fi
echo ./gradlew ${SCALA_VERSION_ARG} ${GRADLE_ARGS} ${EXTRA_ARGS}
if [[ ${use_less} -eq 1 ]]; then
./gradlew ${SCALA_VERSION_ARG} ${GRADLE_ARGS} ${EXTRA_ARGS} 2>&1 | less '+F'
else
exec ./gradlew ${SCALA_VERSION_ARG} ${GRADLE_ARGS} ${EXTRA_ARGS}
fi