-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild
More file actions
executable file
·91 lines (74 loc) · 1.86 KB
/
Copy pathbuild
File metadata and controls
executable file
·91 lines (74 loc) · 1.86 KB
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
#!/usr/bin/env bash
SCRIPT_DIR=$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)
CLEAN=0
BUILD_GS=0
SKIPTEST=""
GS_SRC=$SCRIPT_DIR/Server
_JAR_DIR="$SCRIPT_DIR/builddir"
help()
{
echo "Usage: $0 [-h] [-q] <-g|-c> [-o <path>]";
echo " -h: Display this message.";
echo " -g: Build the game server.";
echo " -c: Clean previous build.";
echo " -o: Specify jar-file directory.";
echo " -q: Quick build - will skip tests.";
}
error()
{
echo "$1";
exit 1;
}
clean_gs()
{
cd $GS_SRC || error "Could not change dir to game server directory."
echo "Cleaning the game server."
sh mvnw clean || error "Failed to clean the game server. Giving up."
}
build_gs()
{
cd "$GS_SRC" || error "ERROR: Could not chdir to server src. Abort."
sh mvnw package $SKIPTEST || \
error "Failed to build the game server. Giving up."
}
while getopts "hqgc:o:d" arg; do
case $arg in
h)
help
exit 0
;;
g)
BUILD_GS=1
;;
c)
CLEAN=1
;;
o)
_JAR_DIR=${OPTARG}
;;
d)
echo "_JAR_DIR=$_JAR_DIR"
;;
q)
SKIPTEST="-DskipTests"
;;
*)
error "Argument -$arg is not a known or valid argument."
;;
esac
done
if [ $BUILD_GS -eq 0 ] && [ $CLEAN -eq 0 ]; then
error "Need to either build or clean at least. See -h for details."
fi
# Inside func is cd so mgmt prob fails if no condition
(( CLEAN )) && clean_gs
# -----------
if [ -d "$_JAR_DIR" ]; then
rm -r "$_JAR_DIR"
fi
mkdir -p "$_JAR_DIR" || error "Failed to create build directory.";
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