From 03d784117269e2cf6ab386820dd27ca0f1dbdac1 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 2 Oct 2018 21:44:03 -0400
Subject: [PATCH] [CI-SKIP] Update test server rebuild logic

Many times I've ran paper test trying to SHUTDOWN
the existing test server, only for it to see that my target folder
is missing (for whatever reason), and it try to build paper to make
the jar exists.

Well, the patch process will wipe out any uncommitted changes, causing
loss of work.

Now we will only build patches if your missing your entire Paper-Server
folder, and only trigger a mvn compile if the jar is missing.
---
 scripts/testServer.sh | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/scripts/testServer.sh b/scripts/testServer.sh
index 6931fff822..0c5a5eb506 100755
--- a/scripts/testServer.sh
+++ b/scripts/testServer.sh
@@ -63,17 +63,24 @@ fi
 # JAR CHECK
 #
 
-jar="$basedir/Paper-Server/target/paper-${minecraftversion}.jar"
+folder="$basedir/Paper-Server"
+jar="$folder/target/paper-${minecraftversion}.jar"
+if [ ! -d "$folder" ]; then
+(
+    echo "Building Patched Repo"
+    cd "$basedir"
+    ./paper patch
+)
+fi
+
 if [ ! -f "$jar" ] || [ "$2" == "build" ] || [ "$3" == "build" ]; then
 (
     echo "Building Paper"
     cd "$basedir"
-    ./paper patch
-    mvn clean install
+    mvn package
 )
 fi
 
-
 #
 # JVM FLAGS
 #