fix: show last 20 lines on build failure and unhide clean errors

Build failures now display a colored error banner with the last 20
lines of Gradle output. Removed stderr suppression from clean_build
so Gradle errors are visible.

Made-with: Cursor
This commit is contained in:
cottongin
2026-03-11 04:38:28 -04:00
parent 741b8cb30a
commit eac81df4b0

View File

@@ -240,19 +240,31 @@ build_release() {
info "Building release APK... (this may take a minute)" info "Building release APK... (this may take a minute)"
echo "" echo ""
local store_file local store_file build_log exit_code
store_file="$(cd "$(dirname "$KEYSTORE_FILE")" && pwd)/$(basename "$KEYSTORE_FILE")" store_file="$(cd "$(dirname "$KEYSTORE_FILE")" && pwd)/$(basename "$KEYSTORE_FILE")"
build_log=$(mktemp)
if ./gradlew assembleRelease \ set +e
./gradlew assembleRelease \
-Pandroid.injected.signing.store.file="$store_file" \ -Pandroid.injected.signing.store.file="$store_file" \
-Pandroid.injected.signing.store.password="$password" \ -Pandroid.injected.signing.store.password="$password" \
-Pandroid.injected.signing.key.alias="$KEY_ALIAS" \ -Pandroid.injected.signing.key.alias="$KEY_ALIAS" \
-Pandroid.injected.signing.key.password="$password"; then -Pandroid.injected.signing.key.password="$password" 2>&1 | tee "$build_log"
exit_code=${PIPESTATUS[0]}
set -e
if [[ $exit_code -eq 0 ]]; then
rm -f "$build_log"
copy_apk "release" copy_apk "release"
else else
echo "" echo ""
error "Build failed. Check the output above for details." echo -e "${RED}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
error "BUILD FAILED"
echo -e "${RED}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo -e "${DIM}Last 20 lines of build output:${NC}"
tail -20 "$build_log"
rm -f "$build_log"
return 1 return 1
fi fi
} }
@@ -261,11 +273,26 @@ build_debug() {
info "Building debug APK..." info "Building debug APK..."
echo "" echo ""
if ./gradlew assembleDebug; then local build_log exit_code
build_log=$(mktemp)
set +e
./gradlew assembleDebug 2>&1 | tee "$build_log"
exit_code=${PIPESTATUS[0]}
set -e
if [[ $exit_code -eq 0 ]]; then
rm -f "$build_log"
copy_apk "debug" copy_apk "debug"
else else
echo "" echo ""
error "Build failed. Check the output above for details." echo -e "${RED}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
error "BUILD FAILED"
echo -e "${RED}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo -e "${DIM}Last 20 lines of build output:${NC}"
tail -20 "$build_log"
rm -f "$build_log"
return 1 return 1
fi fi
} }
@@ -273,7 +300,7 @@ build_debug() {
clean_build() { clean_build() {
info "Cleaning build artifacts..." info "Cleaning build artifacts..."
./gradlew clean 2>/dev/null ./gradlew clean
if [[ -d "$DIST_DIR" ]]; then if [[ -d "$DIST_DIR" ]]; then
rm -rf "$DIST_DIR" rm -rf "$DIST_DIR"