From da4f3ceb1fc1f317a3cca788b6c9b78ffab12de2 Mon Sep 17 00:00:00 2001 From: Kostya Date: Tue, 13 Oct 2026 19:19:40 +0300 Subject: 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. --- tools/package.sh | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'tools/package.sh') 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 ===" # this line is the entire classpath at runtime. for e in $EXECUTABLES; do CPLINE="" - for m in $MODULES; do - [ "$m" = "$e" ] && continue + for m in $(deps_of "$e"); do CPLINE="$CPLINE${CPLINE:+ }$m.jar" done for d in $RUNTIME_LIB_DIRS; do @@ -49,6 +48,7 @@ done echo "=== Packaging ===" for m in $MODULES; do + [ "$m" = "$WAR_MODULE" ] && continue # ships as a WAR, below case " $EXECUTABLES " in *" $m "*) "$JAR" --create --file "$DIST/$m.jar" --main-class "$(mainclass_of "$m")" \ @@ -72,6 +72,39 @@ done [ -f README.pdf ] && cp README.pdf "$DIST/" +echo "=== Exercise 3: WAR ===" +# The WAR carries everything the server needs; Tomcat only provides the servlet API. +WARDIR="$TMP/war" +rm -rf "$WARDIR" && mkdir -p "$WARDIR/WEB-INF/lib" +cp -r "build/classes/$WAR_MODULE" "$WARDIR/WEB-INF/classes" +for m in $(deps_of "$WAR_MODULE"); do + cp "$DIST/$m.jar" "$WARDIR/WEB-INF/lib/" +done +for d in $WAR_LIB_DIRS; do + for j in lib/"$d"/*.jar; do + is_shippable_jar "$j" || continue + cp "$j" "$WARDIR/WEB-INF/lib/" + done +done +EX3="$DIST/ex3" +mkdir -p "$EX3" +"$JAR" --create --file "$EX3/$WAR_NAME.war" -C "$WARDIR" . +echo " $EX3/$WAR_NAME.war" +"$JAR" --list --file "$EX3/$WAR_NAME.war" | grep 'WEB-INF/lib/.' | sed 's/^/ /' + +echo "=== Exercise 3: client directory ===" +CDIR="$EX3/client" +mkdir -p "$CDIR/lib" +cp "$DIST/$CLIENT.jar" "$CDIR/" +for m in $(deps_of "$CLIENT"); do + cp "$DIST/$m.jar" "$CDIR/" +done +for d in $CLIENT_LIB_DIRS; do + cp -r "$DIST/lib/$d" "$CDIR/lib/" +done +cp "$DIST/run-${CLIENT#ui-}.bat" "$CDIR/" +ls "$CDIR" | sed 's/^/ /' + echo "=== Manifest as it actually landed in the jar ===" # Cheapest check that prevents a Level-0: if Main-Class or Class-Path didn't # survive, it surfaces here instead of on the grader's machine. -- cgit v1.2.3