aboutsummaryrefslogtreecommitdiffstats
path: root/tools/package.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/package.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/package.sh')
-rw-r--r--tools/package.sh37
1 files changed, 35 insertions, 2 deletions
diff --git a/tools/package.sh b/tools/package.sh
index ce18f63..2569e96 100644
--- a/tools/package.sh
+++ b/tools/package.sh
@@ -33,8 +33,7 @@ echo "=== Generating executable manifests ==="
33# this line is the entire classpath at runtime. 33# this line is the entire classpath at runtime.
34for e in $EXECUTABLES; do 34for e in $EXECUTABLES; do
35 CPLINE="" 35 CPLINE=""
36 for m in $MODULES; do 36 for m in $(deps_of "$e"); do
37 [ "$m" = "$e" ] && continue
38 CPLINE="$CPLINE${CPLINE:+ }$m.jar" 37 CPLINE="$CPLINE${CPLINE:+ }$m.jar"
39 done 38 done
40 for d in $RUNTIME_LIB_DIRS; do 39 for d in $RUNTIME_LIB_DIRS; do
@@ -49,6 +48,7 @@ done
49 48
50echo "=== Packaging ===" 49echo "=== Packaging ==="
51for m in $MODULES; do 50for m in $MODULES; do
51 [ "$m" = "$WAR_MODULE" ] && continue # ships as a WAR, below
52 case " $EXECUTABLES " in 52 case " $EXECUTABLES " in
53 *" $m "*) 53 *" $m "*)
54 "$JAR" --create --file "$DIST/$m.jar" --main-class "$(mainclass_of "$m")" \ 54 "$JAR" --create --file "$DIST/$m.jar" --main-class "$(mainclass_of "$m")" \
@@ -72,6 +72,39 @@ done
72 72
73[ -f README.pdf ] && cp README.pdf "$DIST/" 73[ -f README.pdf ] && cp README.pdf "$DIST/"
74 74
75echo "=== Exercise 3: WAR ==="
76# The WAR carries everything the server needs; Tomcat only provides the servlet API.
77WARDIR="$TMP/war"
78rm -rf "$WARDIR" && mkdir -p "$WARDIR/WEB-INF/lib"
79cp -r "build/classes/$WAR_MODULE" "$WARDIR/WEB-INF/classes"
80for m in $(deps_of "$WAR_MODULE"); do
81 cp "$DIST/$m.jar" "$WARDIR/WEB-INF/lib/"
82done
83for d in $WAR_LIB_DIRS; do
84 for j in lib/"$d"/*.jar; do
85 is_shippable_jar "$j" || continue
86 cp "$j" "$WARDIR/WEB-INF/lib/"
87 done
88done
89EX3="$DIST/ex3"
90mkdir -p "$EX3"
91"$JAR" --create --file "$EX3/$WAR_NAME.war" -C "$WARDIR" .
92echo " $EX3/$WAR_NAME.war"
93"$JAR" --list --file "$EX3/$WAR_NAME.war" | grep 'WEB-INF/lib/.' | sed 's/^/ /'
94
95echo "=== Exercise 3: client directory ==="
96CDIR="$EX3/client"
97mkdir -p "$CDIR/lib"
98cp "$DIST/$CLIENT.jar" "$CDIR/"
99for m in $(deps_of "$CLIENT"); do
100 cp "$DIST/$m.jar" "$CDIR/"
101done
102for d in $CLIENT_LIB_DIRS; do
103 cp -r "$DIST/lib/$d" "$CDIR/lib/"
104done
105cp "$DIST/run-${CLIENT#ui-}.bat" "$CDIR/"
106ls "$CDIR" | sed 's/^/ /'
107
75echo "=== Manifest as it actually landed in the jar ===" 108echo "=== Manifest as it actually landed in the jar ==="
76# Cheapest check that prevents a Level-0: if Main-Class or Class-Path didn't 109# Cheapest check that prevents a Level-0: if Main-Class or Class-Path didn't
77# survive, it surfaces here instead of on the grader's machine. 110# survive, it surfaces here instead of on the grader's machine.