-
Notifications
You must be signed in to change notification settings - Fork 1
/
mavex.sh
executable file
·366 lines (320 loc) · 6.69 KB
/
mavex.sh
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
#!/bin/sh
# Maven Express for Linux
VERSION="0.5"
# nome projeto
PROJECT="ca"
# inicio da execucao
START=`date`
START_S=$(date +%s)
ROOT_DIR=`pwd`
# arquivo de log
MAVEX_LOG="${ROOT_DIR}/mavexlog.txt"
LIGEIRO_DIR="${ROOT_DIR}/../Ligeiro"
Main() {
echo ""
echo "Maven Express for Linux ${VERSION} [${PROJECT}]"
echo ""
echo "Bom dia ${USER}!"
echo "Para consultar o resultado do maven verifique o arquivo ${MAVEX_LOG}."
echo "Para cancelar o script use \"Ctrl+C\"."
echo "---------------------------------------------------------------------"
if [ $# -eq 0 ]; then
Help
exit 1
fi
case $1 in
"-c")
shift ;
CheckModuleCompileList $* ;
DoTask compile $* ;;
"-d")
shift ;
CheckModuleCompileList $* ;
DoTask deploy $* ;;
"-m")
shift ;
CheckModuleModelList $* ;
CodeGenerate $* ;;
"-t")
shift ;
CheckModuleModelList $* ;
All $* ;;
"-u")
shift ;
CheckModuleCompileList $* ;
DoTask undeploy $* ;;
"-a" | "--all")
shift ;
All "core" "principal" "administracao";;
"--clean")
shift ;
echo "" ;
echo "Limpando projeto..." ;
maven clean >> "${MAVEX_LOG}" ;;
*)
Help ;
exit 1 ;;
esac
}
Help() {
target=$1
if [ "$target" != "" ];then
echo ""
echo "Objetivo inexistente: ${target}"
echo ""
fi
echo "Uso: ${0} [opcao] [lista de objetivos]"
echo ""
echo "[opcao]"
echo "\t -a [--all] \t Gera e compila o codigo de todos os modulos."
echo "\t -c \t\t Compila o codigo e realiza deploy."
echo "\t -d \t\t Realiza o deploy."
echo "\t -m \t\t Gera o codigo."
echo "\t -t \t\t Gera e compila o codigo."
echo "\t -u \t\t Realiza o undeploy."
echo ""
echo "[lista de objetivos para -m -t]"
echo "\t core (inclui subdiretorios e common)"
echo "\t geral"
echo "\t principal (inclui layout)"
echo "\t administracao"
echo ""
echo "[lista de objetivos para -c -d -u]"
echo "\t common"
echo "\t core (common + core)"
echo "\t core-cd"
echo "\t core-only"
echo "\t core-servicos"
echo "\t layout"
echo "\t principal (inclui layout)"
echo "\t administracao"
echo ""
}
CodeGenerate() {
while [ $# -gt 0 ]; do
echo ""
echo "Gerando modelo: ${1}"
echo "Aguarde..."
maven mda -Dprojeto=${PROJECT}-${1} >> "${MAVEX_LOG}"
CheckError ${1} ${1} $?
# mv -vf statistics/statistics_entities.xml ${LIGEIRO_DIR}/data/statistics/jabot/ControleAcesso/statistics_entities_${1}.xml
# mv -vf statistics/statistics_services.xml ${LIGEIRO_DIR}/data/statistics/jabot/ControleAcesso/statistics_services_${1}.xml
# mv -vf statistics/statistics_usecases.xml ${LIGEIRO_DIR}/data/statistics/jabot/ControleAcesso/statistics_usecases_${1}.xml
shift
done
}
DoTask() {
task=$1
shift
case $task in
"compile")
task=0 ;;
"deploy")
task=1 ;;
"undeploy")
task=2 ;;
*) ;;
esac
while [ $# -gt 0 ]; do
echo ""
if [ $task -eq 0 ]; then
echo "Compilando codigo: $1"
elif [ $task -eq 1 ]; then
echo "Realizando deploy: $1"
elif [ $task -eq 2 ]; then
echo "Realizando undeploy: $1"
fi
echo "Aguarde..."
case $1 in
"bpm")
;;
"common")
CompileCoreTarget $task common
;;
"core")
CompileCoreTarget $task common core
;;
"core-cd")
CompileCoreTarget $task core-cd
;;
"core-only")
CompileCoreTarget $task core
;;
"core-servicos")
CompileCoreTarget $task core-servicos
;;
"layout")
CompileWebTarget $1 $task layout
;;
"principal")
CompileWebTarget $1 $task layout
CompileWebTarget $1 $task principal
;;
"administracao")
CompileWebTarget $1 $task administracao
;;
*) ;;
esac
shift
done
}
CompileCoreTarget() {
task=$1
shift
while [ $# -gt 0 ]; do
case $1 in
"common")
echo ""
echo ""
cd "${ROOT_DIR}/common"
if [ $task -eq 0 ]; then
maven jar:install deploy >> "${MAVEX_LOG}"
elif [ $task -eq 1 ]; then
maven deploy >> "${MAVEX_LOG}"
elif [ $task -eq 2 ]; then
maven undeploy >> "${MAVEX_LOG}"
fi
CheckError ${1} "./common" $?
;;
"core")
echo ""
echo ""
cd "${ROOT_DIR}/core"
if [ $task -eq 0 ]; then
maven install deploy >> "${MAVEX_LOG}"
elif [ $task -eq 1 ]; then
maven deploy >> "${MAVEX_LOG}"
elif [ $task -eq 2 ]; then
maven undeploy >> "${MAVEX_LOG}"
fi
CheckError ${1} "./core" $?
;;
"core-cd")
echo ""
echo ""
cd "${ROOT_DIR}/core/cd"
if [ $task -eq 0 ]; then
maven jar:install deploy >> "${MAVEX_LOG}"
elif [ $task -eq 1 ]; then
maven deploy >> "${MAVEX_LOG}"
elif [ $task -eq 2 ]; then
maven undeploy >> "${MAVEX_LOG}"
fi
CheckError ${1} "./core/cd" $?
;;
"core-servicos")
CompileCoreEjbTarget $1 $task servicos
;;
*) ;;
esac
shift
done
}
CompileCoreEjbTarget() {
target=$1
task=$2
module=$3
echo ""
echo ""
cd "${ROOT_DIR}/core/cs/${module}"
if [ $task -eq 0 ]; then
maven ejb:install deploy >> "${MAVEX_LOG}"
elif [ $task -eq 1 ]; then
maven deploy >> "${MAVEX_LOG}"
elif [ $task -eq 2 ]; then
maven undeploy >> "${MAVEX_LOG}"
fi
echo "------ Resultado do maven para ${target} (./core/cs/${module}): $?"
CheckError ${target} "./core/cs/${module}" $?
}
CompileWebTarget() {
target=$1
task=$2
module=$3
echo ""
echo ""
cd "${ROOT_DIR}/web/${module}"
if [ $task -eq 0 ]; then
maven install deploy >> "${MAVEX_LOG}"
elif [ $task -eq 1 ]; then
maven deploy >> "${MAVEX_LOG}"
elif [ $task -eq 2 ]; then
maven undeploy >> "${MAVEX_LOG}"
fi
CheckError ${target} "./web/${module}" $?
}
All() {
CodeGenerate $*
DoTask compile $*
}
CheckModuleModelList() {
for module in $*; do
case $module in
"bpm") ;;
"core") ;;
"principal") ;;
"administracao") ;;
*)
Help $module;
exit 1;;
esac
done
}
CheckModuleCompileList() {
for module in $*; do
case $module in
"bpm") ;;
"common") ;;
"core") ;;
"core-cd") ;;
"core-only") ;;
"core-servicos") ;;
"principal") ;;
"administracao") ;;
"layout") ;;
*)
Help $module;
exit 1;;
esac
done
}
CheckError() {
target=$1
current=$2
status=$3
if [ $status -eq 0 ]; then
echo "------ Resultado do maven para ${target} (${current}): SUCESSO"
else
echo ""
echo "------ Resultado do maven para ${target} (${current}): ERRO"
echo ""
DisplayTime
exit 1
fi
}
DisplayTime() {
# termino da execucao
END=`date`
END_S=$(date +%s)
# tempo de execucao
DIFF=$(( $END_S - $START_S ))
min=`expr $DIFF / 60`
sec=`expr $DIFF - $min \* 60`
if [ $min -lt 10 ]; then
min="0${min}"
fi
if [ $sec -lt 10 ]; then
sec="0${sec}"
fi
echo ""
echo "Tempo de execucao: ${min}:${sec}"
echo "Comecou em: $START"
echo "Terminou em: $END"
echo ""
}
# gerando um novo arquivo de log
cat /dev/null > "${MAVEX_LOG}"
cd "${ROOT_DIR}"
Main $*
DisplayTime
exit 0