aboutsummaryrefslogtreecommitdiffstats
path: root/tools/tomcat.sh
diff options
context:
space:
mode:
authorKostya <mail@sartin.in>2026-10-13 19:19:40 +0300
committerKostya <mail@sartin.in>2026-10-13 19:20:05 +0300
commitda4f3ceb1fc1f317a3cca788b6c9b78ffab12de2 (patch)
treee8c70414409640309461c1b7fabbd084c892eb03 /tools/tomcat.sh
parent4edb27d378e8b79931ef6a6abebfda66f894d538 (diff)
downloadguess-market-da4f3ceb1fc1f317a3cca788b6c9b78ffab12de2.tar.gz
guess-market-da4f3ceb1fc1f317a3cca788b6c9b78ffab12de2.tar.xz
guess-market-da4f3ceb1fc1f317a3cca788b6c9b78ffab12de2.zip
tools: package the server as a WAR and the client as a directory
The Ex3 submission is exactly one WAR for Tomcat's webapps/ plus a directory holding the client, its jars and its batch file. package.sh now stages both under build/dist/ex3. The WAR is named guess-market.war after the context path the client expects, and carries the api and service jars with gson and JAXB; Tomcat only has to provide the servlet API. The client directory holds ui-client, api, ui-fx, gson, OkHttp and JavaFX, and nothing of the engine. An executable's Class-Path used to name every module. List only the modules it depends on, so the client jar no longer points at service.jar, and stop producing a plain jar for the server module. Add tomcat.sh to try the result by hand: it copies the packaged WAR into a local Tomcat ($CATALINA_HOME, or the newest C:\tomcat\apache-tomcat-*) and runs it in the foreground.
Diffstat (limited to 'tools/tomcat.sh')
-rw-r--r--tools/tomcat.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/tools/tomcat.sh b/tools/tomcat.sh
new file mode 100644
index 0000000..05d38d2
--- /dev/null
+++ b/tools/tomcat.sh
@@ -0,0 +1,38 @@
1#!/bin/bash
2
3set -e
4cd "$(dirname "$0")/.."
5. tools/_util.sh
6
7WAR="build/dist/ex3/$WAR_NAME.war"
8[ -f "$WAR" ] || {
9 echo "No $WAR - run tools/package.sh first"
10 exit 1
11}
12
13TOMCAT="${CATALINA_HOME:-$(ls -d /c/tomcat/apache-tomcat-* 2>/dev/null | sort -V | tail -n 1)}"
14case "$(uname -s)" in
15 CYGWIN*|MINGW*|MSYS*) TOMCAT=$(cygpath -u "$TOMCAT" 2>/dev/null || echo "$TOMCAT") ;;
16esac
17[ -d "$TOMCAT/webapps" ] || {
18 echo "No Tomcat found. Set CATALINA_HOME to a Tomcat 10.1+ folder (the one holding webapps/)."
19 exit 1
20}
21
22rm -rf "$TOMCAT/webapps/$WAR_NAME" "$TOMCAT/webapps/$WAR_NAME.war"
23cp "$WAR" "$TOMCAT/webapps/"
24
25echo "=== Tomcat: $TOMCAT ==="
26echo " http://localhost:8080/$WAR_NAME/api/health"
27
28case "$(uname -s)" in
29 CYGWIN*|MINGW*|MSYS*)
30 export CATALINA_HOME=$(cygpath -w "$TOMCAT")
31 export JAVA_HOME=$(cygpath -w "$JAVA_HOME_DIR")
32 exec cmd //c "$CATALINA_HOME\\bin\\catalina.bat" run
33 ;;
34 export CATALINA_HOME="$TOMCAT"
35 export JAVA_HOME="$JAVA_HOME_DIR"
36 exec "$TOMCAT/bin/catalina.sh" run
37 ;;
38esac