120 lines
1.9 KiB
Bash
Executable File
120 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Do NOT use `set -e` with Gradle
|
|
set -u
|
|
|
|
RUN_DIR="run"
|
|
OPTIONS_SRC="./config/options.txt"
|
|
OPTIONS_DST="$RUN_DIR/options.txt"
|
|
|
|
GRADLE="./gradlew"
|
|
GRADLE_FLAGS=(
|
|
"--console=plain"
|
|
"--configuration-cache"
|
|
)
|
|
|
|
# ---------- helpers ----------
|
|
|
|
inject_options() {
|
|
if [[ -f "$OPTIONS_SRC" ]]; then
|
|
echo "[*] Injecting options.txt..."
|
|
cp "$OPTIONS_SRC" "$OPTIONS_DST"
|
|
else
|
|
echo "[!] Warning: $OPTIONS_SRC not found, skipping injection"
|
|
fi
|
|
}
|
|
|
|
ensure_run_dir() {
|
|
if [[ ! -d "$RUN_DIR" ]]; then
|
|
echo "[*] Creating run directory..."
|
|
mkdir -p "$RUN_DIR"
|
|
fi
|
|
}
|
|
|
|
# ---------- actions ----------
|
|
|
|
clean() {
|
|
clear
|
|
echo "[*] Running gradle clean..."
|
|
$GRADLE clean "${GRADLE_FLAGS[@]}"
|
|
}
|
|
|
|
build() {
|
|
clear
|
|
|
|
ensure_run_dir
|
|
inject_options
|
|
|
|
echo "[*] Running client..."
|
|
$GRADLE runClient "${GRADLE_FLAGS[@]}"
|
|
}
|
|
|
|
show_tree() {
|
|
clear
|
|
echo "[*] Project tree (respecting .gitignore):"
|
|
tree --gitignore
|
|
}
|
|
|
|
ship() {
|
|
clear
|
|
echo "[*] Building project..."
|
|
$GRADLE build "${GRADLE_FLAGS[@]}"
|
|
echo "[+] Build ready to ship."
|
|
}
|
|
|
|
# ---------- help ----------
|
|
|
|
help_menu() {
|
|
cat <<'EOF'
|
|
🐿️ S Q U I R R E L B U I L D T O O L 🐿️
|
|
|
|
Usage:
|
|
./chipper [option]
|
|
|
|
Options:
|
|
--clean Run gradle clean
|
|
--build Run client (fast path)
|
|
--tree Show project tree only
|
|
--ship Build project
|
|
--help Show this help menu
|
|
|
|
Notes:
|
|
- Uses Gradle configuration cache
|
|
- Plain console output (no fake progress)
|
|
- Safe to Ctrl+C after EXECUTION starts
|
|
|
|
The squirrel believes in you.
|
|
EOF
|
|
}
|
|
|
|
# ---------- argument parsing ----------
|
|
|
|
if [[ $# -eq 0 ]]; then
|
|
help_menu
|
|
exit 0
|
|
fi
|
|
|
|
case "$1" in
|
|
--clean)
|
|
clean
|
|
;;
|
|
--build)
|
|
build
|
|
;;
|
|
--tree)
|
|
show_tree
|
|
;;
|
|
--ship)
|
|
ship
|
|
;;
|
|
--help|-h)
|
|
help_menu
|
|
;;
|
|
*)
|
|
echo "[!] Unknown option: $1"
|
|
echo ""
|
|
help_menu
|
|
exit 1
|
|
;;
|
|
esac
|