aboutsummaryrefslogtreecommitdiffstats
path: root/tools/package.sh
diff options
context:
space:
mode:
authorKostya <mail@sartin.in>2026-08-18 06:52:47 +0000
committerKostya <mail@sartin.in>2026-08-18 06:52:47 +0000
commitd2688a197bd680580699f05e8194f9180e4832fa (patch)
tree0531ef505b0637c9c4bcc17ab6183a6089e26889 /tools/package.sh
parent13a221ffaefc169d028c7eab6f21ac88052d1d40 (diff)
downloadguess-market-d2688a197bd680580699f05e8194f9180e4832fa.tar.gz
guess-market-d2688a197bd680580699f05e8194f9180e4832fa.tar.xz
guess-market-d2688a197bd680580699f05e8194f9180e4832fa.zip
Add XML schema validation, split build scripts by module, rename BuyMenuCommand to PlaceOrderMenuCommand
Introduces XMLValidatorV1 and deserializer/adapter classes for events, ledgers, markets, users, and trading mechanisms. Replaces the monolithic build.bat/run.sh scripts with per-module tools (_util.sh, build.sh, package.sh, test.sh) that compile in dependency order.
Diffstat (limited to 'tools/package.sh')
-rw-r--r--tools/package.sh82
1 files changed, 82 insertions, 0 deletions
diff --git a/tools/package.sh b/tools/package.sh
new file mode 100644
index 0000000..5877444
--- /dev/null
+++ b/tools/package.sh
@@ -0,0 +1,82 @@
1#!/bin/bash
2
3set -e
4cd "$(dirname "$0")/.."
5. tools/_util.sh
6
7bash tools/build.sh
8
9DIST=build/dist
10rm -rf "$DIST"
11mkdir -p "$DIST"
12
13echo "=== Staging runtime libs beside the jars ==="
14for d in $RUNTIME_LIB_DIRS; do
15 mkdir -p "$DIST/lib/$d"
16 n=0
17 for j in lib/"$d"/*.jar; do
18 is_shippable_jar "$j" || continue # never ship -sources / -javadoc
19 cp "$j" "$DIST/lib/$d/"
20 n=$((n + 1))
21 done
22 echo " lib/$d/ ($n jars)"
23done
24
25echo "=== Generating console manifest ==="
26# Generated from what is actually staged, never hand-maintained. Four silent
27# failure modes: wildcards match nothing; a missing trailing newline makes jar
28# drop the line; paths are relative to this jar; and java -jar ignores -cp, so
29# this line is the entire classpath at runtime.
30MF="$TMP/console-manifest.txt"
31CPLINE=""
32for m in $MODULES; do
33 [ "$m" = ui-console ] && continue
34 CPLINE="$CPLINE${CPLINE:+ }$m.jar"
35done
36for d in $RUNTIME_LIB_DIRS; do
37 for j in "$DIST"/lib/"$d"/*.jar; do
38 [ -f "$j" ] || continue
39 CPLINE="$CPLINE lib/$d/$(basename "$j")"
40 done
41done
42printf 'Class-Path: %s\n\n' "$CPLINE" >"$MF"
43echo " $CPLINE"
44
45echo "=== Packaging ==="
46for m in $MODULES; do
47 if [ "$m" = ui-console ]; then
48 "$JAR" --create --file "$DIST/$m.jar" \
49 --main-class "$MAIN_CLASS" --manifest "$MF" -C "build/classes/$m" .
50 else
51 "$JAR" --create --file "$DIST/$m.jar" -C "build/classes/$m" .
52 fi
53 echo " $DIST/$m.jar"
54done
55
56cat >"$DIST/run.bat" <<'EOF'
57@echo off
58cd /d "%~dp0"
59java -jar "%~dp0ui-console.jar"
60if errorlevel 1 pause
61EOF
62
63echo "=== Manifest as it actually landed in the jar ==="
64# Cheapest check that prevents a Level-0: if Main-Class or Class-Path didn't
65# survive, it surfaces here instead of on the grader's machine.
66rm -rf "$TMP/mf" && mkdir -p "$TMP/mf"
67(cd "$TMP/mf" && "$JAR" -xf "$OLDPWD/$DIST/ui-console.jar" META-INF/MANIFEST.MF)
68sed 's/^/ /' "$TMP/mf/META-INF/MANIFEST.MF"
69
70grep -q '^Main-Class:' "$TMP/mf/META-INF/MANIFEST.MF" || {
71 echo "*** Main-Class missing ***"
72 exit 1
73}
74grep -q 'Class-Path:' "$TMP/mf/META-INF/MANIFEST.MF" || {
75 echo "*** Class-Path missing ***"
76 exit 1
77}
78
79echo "======================================"
80echo "Self-contained output in $DIST"
81echo " cd $DIST && java -jar ui-console.jar"
82echo "======================================"