#!/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 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. 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 echo "=== Packaging ===" for m in $MODULES; do 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" . ;; esac echo " $DIST/$m.jar" done for e in $EXECUTABLES; do cat >"$DIST/run-${e#ui-}.bat" <