From d2688a197bd680580699f05e8194f9180e4832fa Mon Sep 17 00:00:00 2001 From: Kostya Date: Tue, 18 Aug 2026 06:52:47 +0000 Subject: 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. --- tools/package.sh | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tools/package.sh (limited to 'tools/package.sh') 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 @@ +#!/bin/bash + +set -e +cd "$(dirname "$0")/.." +. tools/_util.sh + +bash tools/build.sh + +DIST=build/dist +rm -rf "$DIST" +mkdir -p "$DIST" + +echo "=== Staging runtime libs beside the jars ===" +for d in $RUNTIME_LIB_DIRS; do + mkdir -p "$DIST/lib/$d" + n=0 + for j in lib/"$d"/*.jar; do + is_shippable_jar "$j" || continue # never ship -sources / -javadoc + cp "$j" "$DIST/lib/$d/" + n=$((n + 1)) + done + echo " lib/$d/ ($n jars)" +done + +echo "=== Generating console manifest ===" +# 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")" + done +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 + "$JAR" --create --file "$DIST/$m.jar" -C "build/classes/$m" . + fi + echo " $DIST/$m.jar" +done + +cat >"$DIST/run.bat" <<'EOF' +@echo off +cd /d "%~dp0" +java -jar "%~dp0ui-console.jar" +if errorlevel 1 pause +EOF + +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. +rm -rf "$TMP/mf" && mkdir -p "$TMP/mf" +(cd "$TMP/mf" && "$JAR" -xf "$OLDPWD/$DIST/ui-console.jar" META-INF/MANIFEST.MF) +sed 's/^/ /' "$TMP/mf/META-INF/MANIFEST.MF" + +grep -q '^Main-Class:' "$TMP/mf/META-INF/MANIFEST.MF" || { + echo "*** Main-Class missing ***" + exit 1 +} +grep -q 'Class-Path:' "$TMP/mf/META-INF/MANIFEST.MF" || { + echo "*** Class-Path missing ***" + exit 1 +} + +echo "======================================" +echo "Self-contained output in $DIST" +echo " cd $DIST && java -jar ui-console.jar" +echo "======================================" -- cgit v1.2.3