forked from zstackio/zstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runMavenProfile
executable file
·250 lines (211 loc) · 5.47 KB
/
runMavenProfile
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#!/bin/sh
usage() {
echo "usage:$0 [deploydb|deploy|xml-java-schema|premium|sdk|doc|docpremium|md|mdpremium|openapi]"
}
py() {
if [ -d premium/test-premium ]; then
cd premium/test-premium
else
cd test
fi
mvn test -Dtest=TestGenerateApiPythonClassAndJsonTemplate
cd - > /dev/null
}
pysdk() {
if [ -d premium/test-premium ]; then
cd premium/test-premium
else
cd test
fi
mvn test -Dtest=TestGeneratePythonSDK
cd - > /dev/null
}
apihelper() {
cd test
mvn test -Dtest=TestGenerateApiHelper
cd - > /dev/null
cp ~/ApiHelper.groovy testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy
echo "ApiHelper.groovy is generated at ~/ApiHelper.groovy"
}
doc() {
cd test
mvn test -Dtest=TestGenerateDocTemplate
cd - > /dev/null
}
openapi() {
if [ ! -d premium/test-premium ]; then
echo "opensource version doesn't have this tool"
exit 1
fi
cd tool/doclet
mvn -Dmaven.test.skip=true package
cd -
javadoc -private -doclet org.zstack.tool.doclet.JsonDocLet -docletpath tool/doclet/target/doclet-*-jar-with-dependencies.jar $(find -name *.java)
DOC_OUTPUT=`echo ~/zstack-doclet-output.json`
if [ ! -f $DOC_OUTPUT ]; then
echo "$DOC_OUTPUT not found"
exit 1
fi
cd premium/test-premium
mvn test -Dtest=GenerateSwaggerSpec -DdocletDoc=$DOC_OUTPUT
cd -
echo ""
echo ""
echo ""
echo "***********************************************"
echo "openapi spec generated at ~/zstack-api.yaml"
echo "***********************************************"
}
docpremium() {
if [ -d premium/test-premium ]; then
cd premium/test-premium
else
cd test
fi
mvn test -Dtest=TestGenerateDocTemplate
cd - > /dev/null
}
md() {
cd test
mvn test -Dtest=TestGenerateMarkDownDoc
cd - > /dev/null
}
mdpremium() {
if [ -d premium/test-premium ]; then
cd premium/test-premium
else
cd test
fi
mvn test -Dtest=TestGenerateMarkDownDoc
cd - > /dev/null
}
i18njson() {
./build/zsi18n -s . -j conf/i18n.json
}
i18n() {
./build/zsi18n -j conf/i18n.json -d conf/i18n/
}
foreignkey() {
set -u
if [ -d premium/test-premium ]; then
cd premium/test-premium
else
cd test
fi
mvn test -Dtest=TestGenerateSqlForeignKey
cd - > /dev/null
echo "see ~/zstack-sql/foreignKeys.sql"
}
notification() {
SRC=`pwd`
if [ -d premium/test-premium ]; then
cd premium/test-premium
else
cd test
fi
mvn test -Dtest=GenerateNotificationHelper -Dsrc=$SRC
cd - > /dev/null
}
notificationapi() {
SRC=`pwd`
if [ -d premium/test-premium ]; then
cd premium/test-premium
else
cd test
fi
mvn test -Dtest=GenerateApiNotificationInApiMessage -Dsrc=$SRC
cd - > /dev/null
}
triggerexpression() {
if [ ! -d premium/mevoco ]; then
echo "this command needs premium source code"
exit 1
fi
cd premium/mevoco
mvn -P trigger-expression generate-sources
mkdir -p src/main/java/org/zstack/monitoring/trigger/expression/antlr4
yes | cp target/generated-sources/antlr4/TriggerExpression* src/main/java/org/zstack/monitoring/trigger/expression/antlr4
rm -f target/generated-sources/antlr4/TriggerExpression*
cd - > /dev/null
}
cloudwatchfunction() {
if [ ! -d premium/zwatch ]; then
echo "this command needs premium source code"
exit 1
fi
cd premium/zwatch
mvn -P function generate-sources
mkdir -p src/main/java/org/zstack/zwatch/api/antlr4/
yes | cp target/generated-sources/antlr4/MetricFunction* src/main/java/org/zstack/zwatch/api/antlr4/
rm -f target/generated-sources/antlr4/MetricFunction*
cd - > /dev/null
}
sdk() {
set -u
rm -rf ~/zstack-sdk/java
if [ -d premium/test-premium ]; then
cd premium/test-premium
else
cd test
fi
mvn test -Dtest=TestGenerateSDK
if [ $? -ne 0 ]; then
echo "if you see a compile error, you may try to compile and install the sdk module first"
exit 1
fi
cd - > /dev/null
cd sdk/src/main/java/org/zstack/sdk/
find . -type f | grep -E -v "(ZSClient|ZSConfig|ApiException|AsyncRestState|Completion|Constants|ErrorCode|ErrorCodeList|InternalCompletion|ApiResult|Param|RestInfo|AbstractAction|QueryAction).java" | xargs rm -f
cd -
yes | cp -r ~/zstack-sdk/java/* sdk/src/main/java/
set +u
}
run_profile() {
if test x$1 = x'premium'; then
mvn -Dmaven.test.skip=true -P premium clean install
elif test x$1 = x'md'; then
md
elif test x$1 = x'sdk'; then
sdk
elif test x$1 = x'doc'; then
doc
elif test x$1 = x'docpremium'; then
docpremium
elif test x$1 = x'md'; then
md
elif test x$1 = x'mdpremium'; then
mdpremium
elif test x$1 = x'py'; then
py
elif test x$1 = x'pysdk'; then
pysdk
elif test x$1 = x'apihelper'; then
apihelper
elif test x$1 = x'i18njson'; then
i18njson
elif test x$1 = x'i18n'; then
i18n
elif test x$1 = x'foreignkey'; then
foreignkey
elif test x$1 = x'notification'; then
notification
elif test x$1 = x'notificationapi'; then
notificationapi
elif test x$1 = x'triggerexpression'; then
triggerexpression
elif test x$1 = x'cloudwatchfunction'; then
cloudwatchfunction
elif test x$1 = x'openapi'; then
openapi
else
mvn -pl build -P $1 exec:exec -D$1
fi
}
if [ "$#" -eq 0 ]; then
usage
exit 1
fi
for cmd in $@
do
run_profile ${cmd}
done