-
Notifications
You must be signed in to change notification settings - Fork 7
/
package
executable file
·117 lines (115 loc) · 3.48 KB
/
package
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
#!/bin/bash
cd `dirname $0`
. build/func
ROOT_PATH=`pwd`
BUILD_PATH="${ROOT_PATH}/build"
OUT_PATH="${ROOT_PATH}/outer"
if [ -d $OUT_PATH ]; then
rm -rf $OUT_PATH
fi
mkdir $OUT_PATH
APP_NAME=`getModuleItem ./module.ncf APP_NAME`
if [ -z "${APP_NAME}" ]; then
echo "must setting APP_NAME in module.ncf"
exit 0
fi
cd build
if [ ! -d "tmp" ]; then
mkdir tmp
fi
cd $ROOT_PATH
moduleName=`getModuleItem ./module.ncf "APP_NAME"`;
version=`getModuleItem ./module.ncf "VERSION"`;
if [ ! -d "${OUT_PATH}/${moduleName}" ];then
mkdir ${OUT_PATH}/${moduleName}
fi
if [ -d "${OUT_PATH}/${moduleName}/${version}" ]; then
rm -r "${OUT_PATH}/${moduleName}/${version}"
fi
moduleOutPath="${OUT_PATH}/${moduleName}/${version}"
if [ ! -d "$moduleOutPath" ]; then
mkdir $moduleOutPath
fi
mainClass=`getModuleItem ./module.ncf "MAIN_CLASS"`;
mainClassName=`awk -v s="${mainClass}" 'BEGIN{ len = split(s,ary,"."); print ary[len]}'`
moduleBuildPath="${BUILD_PATH}/tmp"
if [ ! -d "${moduleBuildPath}" ]; then
mkdir "${moduleBuildPath}"
fi
moduleNcf="${moduleBuildPath}/module.1.ncf";
if [ -f $moduleNcf ]; then
rm $moduleNcf
fi
touch $moduleNcf
while read line
do
TEMP=`echo $line|grep -Eo '\[.+\]'`
if [ -n "$TEMP" ]; then
echo "set cfg domain ${TEMP}"
cfgDomain=$TEMP
fi
if [ "${cfgDomain}" != "[JAVA]" ]; then
echo $line >> $moduleNcf
fi
done < ./module.ncf
cfgDomain=""
sedCommand="sed "
${ROOT_PATH}/build/merge-ncf "${ROOT_PATH}/build/module-prod.ncf" $moduleNcf $moduleName
#rm $moduleNcf
sedCommand+=" -e 's/%APP_NAME%/${moduleName}/g' "
sedCommand+=" -e 's/%VERSION%/${version}/g' "
sedCommand+=" -e 's/%MAIN_CLASS%/${mainClass}/g' "
echo $sedCommand
if [ -z `echo "${sedCommand}" | grep -o "%JOPT_XMS%"` ]; then
sedCommand="${sedCommand} -e 's/%JOPT_XMS%/256/g' "
fi
if [ -z `echo "${sedCommand}" | grep -o "%JAVA_OPTS%"` ]; then
sedCommand="${sedCommand} -e 's/%JAVA_OPTS%//g' "
fi
if [ -z `echo "${sedCommand}" | grep -o "%JOPT_XMX%"` ]; then
sedCommand="${sedCommand} -e 's/%JOPT_XMX%/256/g' "
fi
if [ -z `echo "${sedCommand}" | grep -o "%JOPT_METASPACESIZE%"` ]; then
sedCommand="${sedCommand} -e 's/%JOPT_METASPACESIZE%/128/g' "
fi
if [ -z `echo "${sedCommand}" | grep -o "%JOPT_MAXMETASPACESIZE%"` ]; then
sedCommand="${sedCommand} -e 's/%JOPT_MAXMETASPACESIZE%/256/g' "
fi
startSh="${BUILD_PATH}/start-temp"
stopSh="${BUILD_PATH}/stop-temp"
# echo $sedCommand
eval "${sedCommand} ${startSh} > ${moduleBuildPath}/start.sh"
cp "${moduleBuildPath}/start.sh" "${OUT_PATH}/start.sh"
chmod +x "${OUT_PATH}/start.sh"
echo "copy ${moduleBuildPath}/start.sh to ${OUT_PATH}/start.sh"
eval "${sedCommand} ${stopSh} > ${moduleBuildPath}/stop.sh"
cp "${moduleBuildPath}/stop.sh" "${OUT_PATH}/stop.sh"
chmod +x "${OUT_PATH}/stop.sh"
echo "copy ${moduleBuildPath}/stop.sh to ${OUT_PATH}/stop.sh"
cp "${moduleBuildPath}/module.temp.ncf" "${OUT_PATH}/Module.ncf"
echo "copy ${moduleBuildPath}/module.temp.ncf to ${OUT_PATH}/Module.ncf"
cd $ROOT_PATH
mvn package -Dmaven.test.skip=true
mv "target/${APP_NAME}.jar" ${OUT_PATH}/${APP_NAME}-${version}.jar
if [ -d "${OUT_PATH}/lib" ]; then
rm -rf "${OUT_PATH}/lib"
fi
cp -r "target/libs" "${OUT_PATH}/lib"
if [ "$1" == "n" ];
then
cd ./web-ui
yarn
npm run build
rm -rf ../outer/www
mv ./dist ../outer/www
else
if [ "$1" != "" ]; then
echo $1
cd ./web-ui
yarn
npm run build-$1
rm -rf ../outer/www
mv ./dist ../outer/www
fi
fi
echo "============ PACKAGE FINISH 🍺🍺🍺🎉🎉🎉 ==============="