-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathz-test-cat
executable file
·116 lines (99 loc) · 3.2 KB
/
z-test-cat
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
#!/usr/bin/env bash
# this script need gradle android hone
# change this for module
android_build_modules=
android_build_modules[0]=test
#android_build_modules[1]=module
product_flavors=""
product_flavors_list="Test Dev"
# change this for middle or last build job
android_build_task_middle="generate${product_flavors}ReleaseSources"
android_build_task_last="connected${product_flavors}DebugAndroidTest"
shell_run_path=$(cd `dirname $0`; pwd)
checkFuncBack(){
if [ $? -eq 0 ]; then
echo "$1 success"
else
echo "$1 error stop build"
exit 1
fi
}
checkEnv(){
evn_checker=`which $1`
if [ ! -n "evn_checker" ]; then
echo "check event [ $1 ] error exit"
exit 1
else
echo -e "Cli [ $1 ] event check success\n-> $1 at Path: ${evn_checker}"
fi
}
checkGradleModule(){
module_len=${#android_build_modules[@]}
if [ ${module_len} -le 0 ]; then
echo "you set [ android_build_modules ] is empty"
exit 1
fi
setting_gradle_path="${shell_run_path}/settings.gradle"
if [ -f "${setting_gradle_path}" ]; then
echo "Find settings gradle at: ${setting_gradle_path}"
else
echo "can not find settings gradle at ${shell_run_path} exit"
exit 1
fi
for module in ${android_build_modules[@]};
do
find_module_set=`cat ${setting_gradle_path} | grep "$module"`
if [ ! -n "$find_module_set" ]; then
echo -e "check gradle module [ ${module} ] error\nYou are not setting $module at ${setting_gradle_path}"
exit 1
else
echo -e "check gradle module [ ${module} ] success\nAt Path: ${setting_gradle_path}\n-> setting is: ${find_module_set}"
fi
module_path="${shell_run_path}/${module}"
if [ ! -d "${module_path}" ]; then
echo -e "check gradle module [ ${module} ] error\nCode path not find\n->Set at: ${module}\n-> Want Path: ${module_path}"
exit 1
fi
done
}
if [ ! -n "$ANDROID_HOME" ]; then
echo "You are not setting ANDROID_HOME stop build"
exit 1
else
echo -e "You are setting ANDROID_HOME\nAt Path: ${ANDROID_HOME}"
fi
checkEnv git
checkEnv java
checkEnv android
checkEnv gradle
checkGradleModule
if [ ! -x "gradlew" ]; then
echo "this path gradlew not exec just try to fix!"
chmod +x gradlew
else
echo "=> local gradlew can use"
fi
git status
git pull
git branch -v
if [ -n "$1" ];then
echo "you are not set product_flavors, like ${product_flavors_list}, use default"
else
product_flavors=$1
android_build_task_middle="generate${product_flavors}ReleaseSources"
android_build_task_last="connected${product_flavors}DebugAndroidTest"
fi
# if want clean unlock this
echo "-> gradle task clean"
./gradlew clean
for module in ${android_build_modules[@]};
do
echo "-> gradle task ${module}:dependencies"
./gradlew -q ${module}:dependencies
# echo "-> gradle task ${module}:dependencies --refresh-dependencies"
# ./gradlew -q ${module}:dependencies --refresh-dependencies
echo "-> gradle task ${module}:${android_build_task_middle}"
./gradlew ${module}:${android_build_task_middle}
echo "-> gradle task ${module}:${android_build_task_last}"
./gradlew ${module}:${android_build_task_last}
done