-
Notifications
You must be signed in to change notification settings - Fork 3
/
build
executable file
·140 lines (116 loc) · 2.9 KB
/
build
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
#!/usr/bin/env bash
SCRIPT_DIR=$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)
BUILD_MS=0
BUILD_GS=0
CLEAN_MS=0
CLEAN_GS=0
SKIPTEST=""
GS_SRC=$SCRIPT_DIR/Server
MS_SRC=$SCRIPT_DIR/Management-Server
CLEANOPT=""
_JAR_DIR="$SCRIPT_DIR/builddir"
help()
{
echo "Usage: $0 [-h] <-m | -g> [-c <m|g>] [-o <path>]";
echo " -h: Display this message.";
echo " -m: Build the management server.";
echo " -g: Build the game server.";
echo " -c: Clean: m: management, g: gameserver. "
echo " Can specify both. Need at least one if present.";
echo " -o: Specify jar-file directory."
echo " -q: Quick build - will skip tests.";
}
error()
{
echo $1;
exit -1;
}
clean_ms()
{
cd $MS_SRC
if [[ "$CLEANOPT" == *"m"* ]]; then
echo "Cleaning the management server."
sh mvnw clean || error "Failed to clean the MS."
fi
}
clean_gs()
{
cd $GS_SRC;
if [[ "$CLEANOPT" == *"g"* ]]; then
echo "Cleaning the game server."
sh mvnw clean || error "Failed to clean the game server. Giving up."
fi
}
build_ms()
{
cd $MS_SRC
sh mvnw package $SKIPTEST || \
error "Failed to build the management server. Giving up";
}
build_gs()
{
cd $GS_SRC;
sh mvnw package $SKIPTEST || \
error "Failed to build the game server. Giving up."
}
while getopts "hqmgc:o:d" arg; do
case $arg in
h)
help
exit 0
;;
m)
BUILD_MS=1
;;
g)
BUILD_GS=1
;;
c)
CLEANOPT=${OPTARG}
;;
o)
_JAR_DIR=${OPTARG}
;;
d)
echo "BUILD_MS=$BUILD_MS"
echo "BUILD_GS=$BUILD_GS"
echo "CLEANOPT=$CLEANOPT"
echo "_JAR_DIR=$_JAR_DIR"
;;
q)
SKIPTEST="-DskipTests"
;;
esac
done
if [[ $CLEANOPT != "m" ]] \
&& [[ $CLEANOPT != "g" ]] \
&& [[ $CLEANOPT != "mg" ]] \
&& [[ $CLEANOPT != "" ]];
then
error "Invalid cleaning option '$CLEANOPT'. Valid options are 'm', 'g', 'mg' or none."
fi
if [ $BUILD_MS -eq 0 ] && [ $BUILD_GS -eq 0 ] && [[ $CLEANOPT == "" ]]; then
error "Need to build or clean at least one of the modules. See -h for details."
fi
# Conditionals inside the functions.
clean_gs
clean_ms
# -----------
if [ -d $_JAR_DIR ]; then
rm -r $_JAR_DIR
fi
if [ $BUILD_MS -ne 1 ] && [ $BUILD_GS -ne 1 ]; then
echo "No build options specified. Stop."
exit 0
fi
mkdir -p $_JAR_DIR || error "Failed to create build directory.";
if [ $BUILD_MS -eq 1 ]; then
build_ms
# Will never execute if build_ms fails because it quits upon failure.
mv -v $MS_SRC/target/*-with-dependencies.jar $_JAR_DIR/ms.jar
fi
if [ $BUILD_GS -eq 1 ]; then
build_gs
# Will never execute if build_gs fails because it quits upon failure.
mv -v $GS_SRC/target/*-with-dependencies.jar $_JAR_DIR/server.jar
fi