-
Notifications
You must be signed in to change notification settings - Fork 25
/
zzz
executable file
·146 lines (131 loc) · 3.38 KB
/
zzz
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env bash
fail() {
MESSAGE=$1
RED='\033[0;31m'
NC='\033[0m'
echo -e "${RED}Failure: $MESSAGE $NC"
echo ""
exit 1;
}
continue() {
result=$1
MESSAGE=$2
if [ $result -ne 0 ]; then
fail $MESSAGE
fi
}
variant() {
VARIANT="$1"
SETS="$2"
C="${@:3}"
echo ""
if [ "$VARIANT" == "$ROOT" ]; then
git checkout master
continue $? "master/checkout"
git pull
continue $? "master/pull"
BRANCH="$ROOT"
if [ "$BRANCH" != "master" ]; then
git checkout $BRANCH 2>/dev/null || git checkout -b $BRANCH
continue $? "$BRANCH/checkout"
fi
else
git checkout "master-$VARIANT"
continue $? "master-$VARIANT/checkout"
git pull
continue $? "master-$VARIANT/pull"
BRANCH="$ROOT-$VARIANT"
if [ "$BRANCH" != "master-$VARIANT" ]; then
git checkout $BRANCH 2>/dev/null || git checkout -b $BRANCH
continue $? "$BRANCH/checkout"
fi
git merge $ROOT --no-edit
continue $? "$BRANCH/merge $ROOT"
fi
if [ "$C" != "-" ]; then
MESSAGE="$BRANCH/$C (all modules)"
echo $MESSAGE
./gradlew $C
continue $? $MESSAGE
fi
}
publish() {
BRANCH=$1
COMMAND=$2
git checkout $BRANCH
continue $? "$BRANCH/checkout"
git pull
continue $? "$BRANCH/pull"
./gradlew $COMMAND
continue $? "$BRANCH/publish"
}
Usage() {
echo ""
echo "This script will run the given gradle commands over the whole cross-compiled space of this project."
echo ""
echo "Usage: ./zzz <ROOT-BRANCH> <TASK>"
echo ""
echo " ROOT-BRANCH Can be either master or any development branch"
echo " - if it's not master, variant branches will be created automatically"
echo " TASK: "
echo " compile - run compile on all variants"
echo " test - run test on branches only"
echo " test-all - run all tests on root and all variants"
echo " merge - only merge root into all variants"
echo " install - install selected modules sets from all branches into local maven"
echo " publish - publish all master and variant modules to sonatype central repo"
echo ""
echo ""
}
if [ -z "$1" ]; then
Usage
fail "Missing root branch argument"
fi
ROOT="$1"
case "$2" in
compile)
C="compile"
RUN_ON_ROOT="true"
RUN_ON_VARIANTS="true"
;;
test-all)
C="test --quiet"
RUN_ON_ROOT="true"
RUN_ON_VARIANTS="true"
;;
test)
C="test --quiet"
RUN_ON_ROOT="false"
RUN_ON_VARIANTS="true"
;;
merge)
C="-"
RUN_ON_ROOT="false"
RUN_ON_VARIANTS="true"
;;
build)
C="build"
RUN_ON_ROOT="true"
RUN_ON_VARIANTS="true"
;;
*)
Usage
fail "Invalid <TASK> argument"
;;
esac
if [ -z "$3" ]; then
SETS="-"
else
SETS="$3"
fi
#excute on the root branch
if [ "$RUN_ON_ROOT" == "true" ]; then
variant "$ROOT" "$SETS" "$C"
fi
#excute on the variant branches
if [ "$RUN_ON_VARIANTS" == "true" ]; then
variant "1.1" "$SETS" $C
variant "1.0" "$SETS" $C
fi
git checkout "$ROOT"
continue $? "Checkout back to root branch"