summaryrefslogtreecommitdiffstats
path: root/tools/package.sh
diff options
context:
space:
mode:
authorKostya <mail@sartin.in>2026-08-23 14:05:29 +0000
committerKostya <mail@sartin.in>2026-08-23 14:05:29 +0000
commit843820ea9f357220d69f3795f3289ee41eed355c (patch)
tree57323a2e1cd4d4c0addd57eadc31d0f36c612e96 /tools/package.sh
parentfbfd2e275e9d645e4ec8a1874bc57d98b1c38300 (diff)
downloadguess-market-843820ea9f357220d69f3795f3289ee41eed355c.tar.gz
guess-market-843820ea9f357220d69f3795f3289ee41eed355c.tar.xz
guess-market-843820ea9f357220d69f3795f3289ee41eed355c.zip
model: relocate market DTOs out of the flat api package
Move AccountDTO/MarketDTO/MarketStateDTO/PurchaseReceiptDTO/TradeRowDTO out of the catch-all api package into model.market (and LedgerDTO into model.ledger), matching the existing model.event convention so DTOs live next to the domain they describe rather than in the interface package. Relocate LedgerMapper from mapper.v2 to infrastructure.adapter to match the module's established package layout, and update all call sites and imports accordingly. Also register the ui-desktop module in the build tooling: add it to MODULES, add openjfx to the shipped runtime libs, and generalize package.sh so each executable module (ui-console, ui-desktop) gets its own Main-Class/Class-Path manifest and run script instead of special-casing ui-console. Fold long Class-Path manifest lines at 72 bytes per the JAR spec, since adding ui-desktop's dependencies pushed the line past the limit.
Diffstat (limited to 'tools/package.sh')
-rw-r--r--tools/package.sh75
1 files changed, 43 insertions, 32 deletions
diff --git a/tools/package.sh b/tools/package.sh
index a85ee6c..186dab5 100644
--- a/tools/package.sh
+++ b/tools/package.sh
@@ -22,63 +22,74 @@ for d in $RUNTIME_LIB_DIRS; do
22 echo " lib/$d/ ($n jars)" 22 echo " lib/$d/ ($n jars)"
23done 23done
24 24
25echo "=== Generating console manifest ===" 25echo "=== Generating executable manifests ==="
26# Generated from what is actually staged, never hand-maintained. Four silent 26# Generated from what is actually staged, never hand-maintained. Four silent
27# failure modes: wildcards match nothing; a missing trailing newline makes jar 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 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. 29# this line is the entire classpath at runtime.
30MF="$TMP/console-manifest.txt" 30for e in $EXECUTABLES; do
31CPLINE="" 31 CPLINE=""
32for m in $MODULES; do 32 for m in $MODULES; do
33 [ "$m" = ui-console ] && continue 33 [ "$m" = "$e" ] && continue
34 CPLINE="$CPLINE${CPLINE:+ }$m.jar" 34 CPLINE="$CPLINE${CPLINE:+ }$m.jar"
35done 35 done
36for d in $RUNTIME_LIB_DIRS; do 36 for d in $RUNTIME_LIB_DIRS; do
37 for j in "$DIST"/lib/"$d"/*.jar; do 37 for j in "$DIST"/lib/"$d"/*.jar; do
38 [ -f "$j" ] || continue 38 [ -f "$j" ] || continue
39 CPLINE="$CPLINE lib/$d/$(basename "$j")" 39 CPLINE="$CPLINE lib/$d/$(basename "$j")"
40 done
40 done 41 done
42 write_manifest_attr "$TMP/$e-manifest.txt" "Class-Path" "$CPLINE"
43 echo " $e: $CPLINE"
41done 44done
42printf 'Class-Path: %s\n\n' "$CPLINE" >"$MF"
43echo " $CPLINE"
44 45
45echo "=== Packaging ===" 46echo "=== Packaging ==="
46for m in $MODULES; do 47for m in $MODULES; do
47 if [ "$m" = ui-console ]; then 48 case " $EXECUTABLES " in
48 "$JAR" --create --file "$DIST/$m.jar" \ 49 *" $m "*)
49 --main-class "$MAIN_CLASS" --manifest "$MF" -C "build/classes/$m" . 50 "$JAR" --create --file "$DIST/$m.jar" --main-class "$(mainclass_of "$m")" \
50 else 51 --manifest "$TMP/$m-manifest.txt" -C "build/classes/$m" .
52 ;;
53 *)
51 "$JAR" --create --file "$DIST/$m.jar" -C "build/classes/$m" . 54 "$JAR" --create --file "$DIST/$m.jar" -C "build/classes/$m" .
52 fi 55 ;;
56 esac
53 echo " $DIST/$m.jar" 57 echo " $DIST/$m.jar"
54done 58done
55 59
56cat >"$DIST/run.bat" <<'EOF' 60for e in $EXECUTABLES; do
61 cat >"$DIST/run-${e#ui-}.bat" <<EOF
57@echo off 62@echo off
58cd /d "%~dp0" 63cd /d "%~dp0"
59java -jar "%~dp0ui-console.jar" 64java -jar "%~dp0$e.jar"
60if errorlevel 1 pause 65if errorlevel 1 pause
61EOF 66EOF
67done
62 68
63[ -f README.pdf ] && cp README.pdf "$DIST/" 69[ -f README.pdf ] && cp README.pdf "$DIST/"
64 70
65echo "=== Manifest as it actually landed in the jar ===" 71echo "=== Manifest as it actually landed in the jar ==="
66# Cheapest check that prevents a Level-0: if Main-Class or Class-Path didn't 72# Cheapest check that prevents a Level-0: if Main-Class or Class-Path didn't
67# survive, it surfaces here instead of on the grader's machine. 73# survive, it surfaces here instead of on the grader's machine.
68rm -rf "$TMP/mf" && mkdir -p "$TMP/mf" 74for e in $EXECUTABLES; do
69(cd "$TMP/mf" && "$JAR" -xf "$OLDPWD/$DIST/ui-console.jar" META-INF/MANIFEST.MF) 75 rm -rf "$TMP/mf" && mkdir -p "$TMP/mf"
70sed 's/^/ /' "$TMP/mf/META-INF/MANIFEST.MF" 76 (cd "$TMP/mf" && "$JAR" -xf "$OLDPWD/$DIST/$e.jar" META-INF/MANIFEST.MF)
77 echo "-- $e.jar --"
78 sed 's/^/ /' "$TMP/mf/META-INF/MANIFEST.MF"
71 79
72grep -q '^Main-Class:' "$TMP/mf/META-INF/MANIFEST.MF" || { 80 grep -q '^Main-Class:' "$TMP/mf/META-INF/MANIFEST.MF" || {
73 echo "*** Main-Class missing ***" 81 echo "*** Main-Class missing in $e.jar ***"
74 exit 1 82 exit 1
75} 83 }
76grep -q 'Class-Path:' "$TMP/mf/META-INF/MANIFEST.MF" || { 84 grep -q 'Class-Path:' "$TMP/mf/META-INF/MANIFEST.MF" || {
77 echo "*** Class-Path missing ***" 85 echo "*** Class-Path missing in $e.jar ***"
78 exit 1 86 exit 1
79} 87 }
88done
80 89
81echo "======================================" 90echo "======================================"
82echo "Self-contained output in $DIST" 91echo "Self-contained output in $DIST"
83echo " cd $DIST && java -jar ui-console.jar" 92for e in $EXECUTABLES; do
93 echo " cd $DIST && java -jar $e.jar"
94done
84echo "======================================" 95echo "======================================"