diff options
| author | Kostya <mail@sartin.in> | 2026-10-13 19:19:40 +0300 |
|---|---|---|
| committer | Kostya <mail@sartin.in> | 2026-10-13 19:20:05 +0300 |
| commit | da4f3ceb1fc1f317a3cca788b6c9b78ffab12de2 (patch) | |
| tree | e8c70414409640309461c1b7fabbd084c892eb03 /tools/package.sh | |
| parent | 4edb27d378e8b79931ef6a6abebfda66f894d538 (diff) | |
| download | guess-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.sh | 37 |
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. |
| 34 | for e in $EXECUTABLES; do | 34 | for 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 | ||
| 50 | echo "=== Packaging ===" | 49 | echo "=== Packaging ===" |
| 51 | for m in $MODULES; do | 50 | for 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 | ||
| 75 | echo "=== Exercise 3: WAR ===" | ||
| 76 | # The WAR carries everything the server needs; Tomcat only provides the servlet API. | ||
| 77 | WARDIR="$TMP/war" | ||
| 78 | rm -rf "$WARDIR" && mkdir -p "$WARDIR/WEB-INF/lib" | ||
| 79 | cp -r "build/classes/$WAR_MODULE" "$WARDIR/WEB-INF/classes" | ||
| 80 | for m in $(deps_of "$WAR_MODULE"); do | ||
| 81 | cp "$DIST/$m.jar" "$WARDIR/WEB-INF/lib/" | ||
| 82 | done | ||
| 83 | for 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 | ||
| 88 | done | ||
| 89 | EX3="$DIST/ex3" | ||
| 90 | mkdir -p "$EX3" | ||
| 91 | "$JAR" --create --file "$EX3/$WAR_NAME.war" -C "$WARDIR" . | ||
| 92 | echo " $EX3/$WAR_NAME.war" | ||
| 93 | "$JAR" --list --file "$EX3/$WAR_NAME.war" | grep 'WEB-INF/lib/.' | sed 's/^/ /' | ||
| 94 | |||
| 95 | echo "=== Exercise 3: client directory ===" | ||
| 96 | CDIR="$EX3/client" | ||
| 97 | mkdir -p "$CDIR/lib" | ||
| 98 | cp "$DIST/$CLIENT.jar" "$CDIR/" | ||
| 99 | for m in $(deps_of "$CLIENT"); do | ||
| 100 | cp "$DIST/$m.jar" "$CDIR/" | ||
| 101 | done | ||
| 102 | for d in $CLIENT_LIB_DIRS; do | ||
| 103 | cp -r "$DIST/lib/$d" "$CDIR/lib/" | ||
| 104 | done | ||
| 105 | cp "$DIST/run-${CLIENT#ui-}.bat" "$CDIR/" | ||
| 106 | ls "$CDIR" | sed 's/^/ /' | ||
| 107 | |||
| 75 | echo "=== Manifest as it actually landed in the jar ===" | 108 | echo "=== 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. |