From 843820ea9f357220d69f3795f3289ee41eed355c Mon Sep 17 00:00:00 2001 From: Kostya Date: Sun, 23 Aug 2026 14:05:29 +0000 Subject: 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. --- tools/_util.sh | 27 +++++++++++++++++--- tools/package.sh | 75 ++++++++++++++++++++++++++++++++------------------------ 2 files changed, 67 insertions(+), 35 deletions(-) (limited to 'tools') diff --git a/tools/_util.sh b/tools/_util.sh index fde4797..a041f2d 100644 --- a/tools/_util.sh +++ b/tools/_util.sh @@ -5,15 +5,18 @@ case "$(uname -s)" in *) SEP=":" ;; esac -MODULES="api service ui-console" +MODULES="api service ui-console ui-desktop" DEPS_api="" DEPS_service="api" DEPS_ui_console="api service" +DEPS_ui_desktop="" -RUNTIME_LIB_DIRS="pico jaxb gson" +RUNTIME_LIB_DIRS="pico jaxb gson openjfx" -MAIN_CLASS="market.guess.ui.console.App" +EXECUTABLES="ui-console ui-desktop" +MAINCLASS_ui_console="market.guess.ui.console.App" +MAINCLASS_ui_desktop="market.guess.ui.desktop.Launcher" JAVA_HOME_DIR=$(java -XshowSettings:properties -version 2>&1 | tr -d '\r' | sed -n 's/^ *java\.home = //p') case "$(uname -s)" in @@ -45,6 +48,24 @@ deps_of() { eval "printf '%s' \"\${$v}\"" } +mainclass_of() { + local v="MAINCLASS_$(echo "$1" | tr '-' '_')" + eval "printf '%s' \"\${$v}\"" +} + +# JAR manifest lines are capped at 72 bytes; a raw "Key: value" line trips +# `line too long` once enough jars are on the Class-Path (openjfx pushed us +# over it). Fold per spec: continuation lines start with a single space. +write_manifest_attr() { + local file="$1" line="$2: $3" + : >"$file" + while [ "${#line}" -gt 72 ]; do + printf '%s\n' "${line:0:72}" >>"$file" + line=" ${line:72}" + done + printf '%s\n\n' "$line" >>"$file" +} + module_cp() { local cp="" for d in "$@"; do cp="$cp${cp:+$SEP}build/classes/$d"; done 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 echo " lib/$d/ ($n jars)" done -echo "=== Generating console manifest ===" +echo "=== Generating executable manifests ===" # Generated from what is actually staged, never hand-maintained. Four silent # failure modes: wildcards match nothing; a missing trailing newline makes jar # drop the line; paths are relative to this jar; and java -jar ignores -cp, so # this line is the entire classpath at runtime. -MF="$TMP/console-manifest.txt" -CPLINE="" -for m in $MODULES; do - [ "$m" = ui-console ] && continue - CPLINE="$CPLINE${CPLINE:+ }$m.jar" -done -for d in $RUNTIME_LIB_DIRS; do - for j in "$DIST"/lib/"$d"/*.jar; do - [ -f "$j" ] || continue - CPLINE="$CPLINE lib/$d/$(basename "$j")" +for e in $EXECUTABLES; do + CPLINE="" + for m in $MODULES; do + [ "$m" = "$e" ] && continue + CPLINE="$CPLINE${CPLINE:+ }$m.jar" + done + for d in $RUNTIME_LIB_DIRS; do + for j in "$DIST"/lib/"$d"/*.jar; do + [ -f "$j" ] || continue + CPLINE="$CPLINE lib/$d/$(basename "$j")" + done done + write_manifest_attr "$TMP/$e-manifest.txt" "Class-Path" "$CPLINE" + echo " $e: $CPLINE" done -printf 'Class-Path: %s\n\n' "$CPLINE" >"$MF" -echo " $CPLINE" echo "=== Packaging ===" for m in $MODULES; do - if [ "$m" = ui-console ]; then - "$JAR" --create --file "$DIST/$m.jar" \ - --main-class "$MAIN_CLASS" --manifest "$MF" -C "build/classes/$m" . - else + case " $EXECUTABLES " in + *" $m "*) + "$JAR" --create --file "$DIST/$m.jar" --main-class "$(mainclass_of "$m")" \ + --manifest "$TMP/$m-manifest.txt" -C "build/classes/$m" . + ;; + *) "$JAR" --create --file "$DIST/$m.jar" -C "build/classes/$m" . - fi + ;; + esac echo " $DIST/$m.jar" done -cat >"$DIST/run.bat" <<'EOF' +for e in $EXECUTABLES; do + cat >"$DIST/run-${e#ui-}.bat" <