-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathz-test-compileRelease
executable file
·137 lines (117 loc) · 3.85 KB
/
z-test-compileRelease
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
#!/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=""
# change this for middle or last build job
android_build_task_middle="generate${product_flavors}ReleaseSources"
android_build_task_last="compile${product_flavors}ReleaseJavaWithJavac"
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 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 --info"
./gradlew ${module}:dependencies --refresh-dependencies --info
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
# jenkins config first Invoke Gradle script
echo -e "\nJenkins config \033[;36mInvoke Gradle script\033[0m"
echo -e "\033[;34mTasks\033[0m"
echo -e "clean --refresh-dependencies"
# jenkins config Invoke Gradle script
echo -e "\nJenkins config \033[;36mInvoke Gradle script\033[0m"
echo -e "\033[;34mTasks\033[0m"
for module in ${android_build_modules[@]};
do
echo -e "-q :${module}:dependencies"
done
# jenkins config Invoke Gradle script
echo -e "\nJenkins config \033[;36mInvoke Gradle script\033[0m"
echo -e "\033[;34mTasks\033[0m"
for module in ${android_build_modules[@]};
do
echo -e "-q :${module}:${android_build_task_middle}"
echo -e "-q :${module}:${android_build_task_last}"
done
# jenkins config Invoke Gradle script
echo -e "\nJenkins config \033[;36mInvoke Gradle script\033[0m"
echo -e "\033[;34mTasks\033[0m"
for module in ${android_build_modules[@]};
do
echo -e ":${module}:assemble${product_flavors}Release --profile"
done