mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-09 16:45:44 -07:00
Rewritten and much improved bash build script
Rewritten and much improved bash run script Rewritten .gitignore
This commit is contained in:
parent
28d9a58a6e
commit
177560aefc
8 changed files with 326 additions and 65 deletions
52
.gitignore
vendored
52
.gitignore
vendored
|
|
@ -1,49 +1,27 @@
|
||||||
/Management-Server/build/
|
builddir
|
||||||
/Management-Server/build/classes/
|
logs
|
||||||
/Management-Server/build/tmp/
|
Management-Server/target/*
|
||||||
/Management-Server/build/kotlin/
|
|
||||||
/Management-Server/build/generated/
|
|
||||||
/Client/build/
|
|
||||||
/Client/build/classes/
|
|
||||||
/Client/build/tmp/
|
|
||||||
/Client/build/kotlin/
|
|
||||||
/Client/build/generated/
|
|
||||||
/Server/build/
|
|
||||||
/Server/build/classes/
|
|
||||||
/Server/build/tmp/
|
|
||||||
/Server/build/kotlin/
|
|
||||||
/Server/build/generated/
|
|
||||||
/Server/data/eco/bot_offers.json
|
|
||||||
/File-Server/build/
|
|
||||||
/File-Server/build/classes/
|
|
||||||
/File-Server/build/tmp/
|
|
||||||
/File-Server/build/kotlin/
|
|
||||||
/File-Server/build/generated/
|
|
||||||
**/.idea/workspace.xml
|
|
||||||
**/.idea/tasks.xml
|
|
||||||
Server/**/*.class
|
|
||||||
CompiledServer/*
|
|
||||||
CompiledServer/
|
|
||||||
Server/gradle/
|
|
||||||
Server/build/
|
|
||||||
Server/.gradle/
|
|
||||||
Client/gradle/
|
|
||||||
Client/build/
|
|
||||||
Client/.gradle/
|
|
||||||
Management-Server/.gradle
|
Management-Server/.gradle
|
||||||
Management-Server/build/
|
Management-Server/build/
|
||||||
Management-Server/org/
|
Management-Server/org/
|
||||||
|
Server/target/*
|
||||||
|
Server/data/eco/bot_offers.json
|
||||||
|
Server/gradle/
|
||||||
|
Server/**/*.class
|
||||||
|
Server/build/
|
||||||
|
Server/.gradle/
|
||||||
Server/data/eco/grand_exchange_db.emp
|
Server/data/eco/grand_exchange_db.emp
|
||||||
Single-Player/*
|
Server/ge_test.db
|
||||||
Single-Player/
|
Management-Server/managementprops/
|
||||||
|
Server/worldprops/
|
||||||
|
|
||||||
|
**/.idea/workspace.xml
|
||||||
|
**/.idea/tasks.xml
|
||||||
docker
|
docker
|
||||||
.gradle
|
.gradle
|
||||||
gradle
|
gradle
|
||||||
.idea
|
.idea
|
||||||
.idea/
|
.idea/
|
||||||
Server/worldprops/
|
|
||||||
Management-Server/managementprops/
|
|
||||||
/Development-Client/
|
|
||||||
**/*.swp
|
**/*.swp
|
||||||
**/*.swo
|
**/*.swo
|
||||||
build/kotlin/sessions/
|
build/kotlin/sessions/
|
||||||
|
|
|
||||||
140
build
Executable file
140
build
Executable file
|
|
@ -0,0 +1,140 @@
|
||||||
|
#!/bin/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
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
cd Management-Server
|
|
||||||
sh mvnw package
|
|
||||||
mv target/*with-dependencies.jar ms.jar
|
|
||||||
echo "Jar built and moved to Management-Server/ms.jar"
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
cd Server
|
|
||||||
sh mvnw package
|
|
||||||
mv target/*with-dependencies.jar server.jar
|
|
||||||
echo "Jar built and moved to Server/server.jar"
|
|
||||||
171
run
Executable file
171
run
Executable file
|
|
@ -0,0 +1,171 @@
|
||||||
|
#!/bin/bash
|
||||||
|
SCRIPT_DIR=$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)
|
||||||
|
LOG_DIR=$SCRIPT_DIR/logs
|
||||||
|
BUILD_DIR=$SCRIPT_DIR/builddir
|
||||||
|
GS_SRC=$SCRIPT_DIR/Server
|
||||||
|
MS_SRC=$SCRIPT_DIR/Management-Server
|
||||||
|
|
||||||
|
FORCE_REBUILD=0
|
||||||
|
REFRESH_BUILD=1
|
||||||
|
|
||||||
|
GAMESERVER_ONLY=1
|
||||||
|
|
||||||
|
GS_EXEC="cd $GS_SRC && java -Dnashorn.args=--no-deprecation-warning -jar $BUILD_DIR/server.jar"
|
||||||
|
MS_EXEC="cd $MS_SRC && java -Dnashorn.args=--no-deprecation-warning -jar $BUILD_DIR/ms.jar"
|
||||||
|
|
||||||
|
# 0: parallel
|
||||||
|
# 1: fancy tmux
|
||||||
|
# 2: tests only
|
||||||
|
RUN_MODE=0
|
||||||
|
|
||||||
|
help()
|
||||||
|
{
|
||||||
|
echo "Usage: $0 [-h] [-q] [-r] [-t] [-x] [-g] [-e <filename>] [-o <filename>]"
|
||||||
|
echo " -h: Display this message."
|
||||||
|
echo " -q: Don't perform the incremental build."
|
||||||
|
echo " -r: Force clean rebuild."
|
||||||
|
echo " -t: Only run tests, not the JARs."
|
||||||
|
echo " -x: Run in a fancy tmux session."
|
||||||
|
echo " -g: Build + run only the game server (no management server)."
|
||||||
|
echo " -e: Write STDERR to 'logs/filename' as well as the terminal.";
|
||||||
|
echo " -o: Write STDOUT to 'logs/filename' as well as the terminal."
|
||||||
|
}
|
||||||
|
|
||||||
|
error()
|
||||||
|
{
|
||||||
|
echo "$1";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
rebuild_project()
|
||||||
|
{
|
||||||
|
if [ $GAMESERVER_ONLY ]; then
|
||||||
|
$SCRIPT_DIR/build -qgcg
|
||||||
|
else
|
||||||
|
$SCRIPT_DIR/build -qmgcmg
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh_project()
|
||||||
|
{
|
||||||
|
if [ $GAMESERVER_ONLY ]; then
|
||||||
|
$SCRIPT_DIR/build -qg
|
||||||
|
else
|
||||||
|
$SCRIPT_DIR/build -qmg
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
verify_binaries_exist()
|
||||||
|
{
|
||||||
|
if ! [ $GAMESERVER_ONLY ]; then
|
||||||
|
if [ ! -f $SCRIPT_DIR/builddir/ms.jar ]; then
|
||||||
|
error "Management server binary does not exist.";
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f $SCRIPT_DIR/build/server.jar ]; then
|
||||||
|
error "Game server binary does not exist.";
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
run_server_parallel()
|
||||||
|
{
|
||||||
|
if ! [ -x "$(command -v java)" ]; then
|
||||||
|
error "Java is not installed."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Running in parallel. All logs redirected to proper files."
|
||||||
|
|
||||||
|
if [ $GAMESERVER_ONLY ]; then
|
||||||
|
sh -c "$GS_EXEC" & wait
|
||||||
|
else
|
||||||
|
sh -c "$MS_EXEC > $LOG_DIR/ms_stdout.log 2> $LOG_DIR/ms_stderr.log & $GS_EXEC" & wait
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
run_server_tmux()
|
||||||
|
{
|
||||||
|
if ! [ -x "$(command -v tmux)" ]; then
|
||||||
|
error "tmux is not installed. Install tmux or don't use this option."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $GAMESERVER_ONLY ]; then
|
||||||
|
tmux new-session "$GS_EXEC"
|
||||||
|
else
|
||||||
|
tmux new-session "$MS_EXEC" \; \
|
||||||
|
split-window -h "$GS_EXEC"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
run_server_tests()
|
||||||
|
{
|
||||||
|
cd "$GS_SRC" || error "Could not change to GameServer source directory."
|
||||||
|
sh mvnw test
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts ":ghqrtxe:o:" arg; do
|
||||||
|
case $arg in
|
||||||
|
h)
|
||||||
|
help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
q)
|
||||||
|
REFRESH_BUILD=0
|
||||||
|
;;
|
||||||
|
r)
|
||||||
|
FORCE_REBUILD=1
|
||||||
|
;;
|
||||||
|
t)
|
||||||
|
RUN_MODE=2
|
||||||
|
;;
|
||||||
|
o)
|
||||||
|
GS_EXEC="$GS_EXEC > >(tee $LOG_DIR/${OPTARG})"
|
||||||
|
;;
|
||||||
|
e)
|
||||||
|
GS_EXEC="$GS_EXEC 2> >(tee $LOG_DIR/${OPTARG})"
|
||||||
|
;;
|
||||||
|
x)
|
||||||
|
RUN_MODE=1
|
||||||
|
;;
|
||||||
|
g)
|
||||||
|
GAMESERVER_ONLY=0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "Argument -$arg is not a known or valid argument."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d $LOG_DIR ]; then
|
||||||
|
mkdir -p $LOG_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d $GS_SRC/target ]; then
|
||||||
|
rebuild_project || error "Failed to perform a clean build."
|
||||||
|
else
|
||||||
|
if [ $FORCE_REBUILD -eq 1 ]; then
|
||||||
|
rebuild_project || error "Failed to perform a clean build."
|
||||||
|
else
|
||||||
|
if [ $REFRESH_BUILD -eq 1 ]; then
|
||||||
|
refresh_project || error "Failed to perform an incremental build."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi;
|
||||||
|
|
||||||
|
cd "$SCRIPT_DIR/builddir" || error "Failed to navigate to the build directory."
|
||||||
|
|
||||||
|
case $RUN_MODE in
|
||||||
|
0)
|
||||||
|
# The trap will allow the script to kill the background
|
||||||
|
# Java instances upon exiting.
|
||||||
|
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
|
||||||
|
|
||||||
|
run_server_parallel
|
||||||
|
;;
|
||||||
|
1)
|
||||||
|
run_server_tmux
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
run_server_tests
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
cd Management-Server
|
|
||||||
sh mvnw package
|
|
||||||
mv target/*with-dependencies.jar /tmp/ms.jar
|
|
||||||
java -jar /tmp/ms.jar
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
cd Server
|
|
||||||
sh mvnw test
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cd Server
|
|
||||||
if [ ! -f hasRun.txt ]; then
|
|
||||||
sh mvnw clean
|
|
||||||
touch hasRun.txt
|
|
||||||
fi
|
|
||||||
sh mvnw package -DskipTests
|
|
||||||
mv target/*with-dependencies.jar /tmp/server.jar
|
|
||||||
java -jar /tmp/server.jar
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue