-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpackage
executable file
·143 lines (136 loc) · 4.2 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
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
#!/bin/bash
cd `dirname $0`
. build/func
echo "$1 ======="
BASE_MODULES="$(pwd)/.base_modules"
if [ -n "$1" ]; then
if [ -f "$BASE_MODULES" ]; then
rm -f "$BASE_MODULES"
fi
IFS=',' read -ra ddm <<< "$1"
for i in "${ddm[@]}"; do
echo $i >> "$BASE_MODULES"
done
fi
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
hasPackageModule(){
while read line
do
if [ "${line}" == $1 ]; then
echo '1';
fi
done < $BASE_MODULES
}
moduleDynamicDependent=`getModuleItem ./module.ncf "moduleDynamicDependent"`; #模块动态依赖
dependent=
if [ -n "${moduleDynamicDependent}" ]; then
IFS=',' read -ra ddm <<< "${moduleDynamicDependent}"
for i in "${ddm[@]}"; do
isPackage=`hasPackageModule $i`
if [ "${isPackage}" == "1" ]; then
if [ -n "$dependent" ]; then
dependent="${dependent},"
fi
dependent="${dependent}${i}"
fi
done
if [ -n "$dependent" ];
then
echo "dynamic dependent : $dependent"
echo "dependent=$dependent" >> $moduleNcf
fi
fi
${ROOT_PATH}/build/merge-ncf "${ROOT_PATH}/build/module-prod.ncf" $moduleNcf $moduleName
cfgDomain=""
sedCommand="sed "
#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 -Dskip.assembly.plugin=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"
echo "============ PACKAGE FINISH 🍺🍺🍺🎉🎉🎉 ==============="