From 0da6a542bdd7250169bf89d4b483360f9dc7a038 Mon Sep 17 00:00:00 2001 From: iris <2+iris@noreply.localhost> Date: Wed, 26 Aug 2026 00:02:43 -0400 Subject: [PATCH] Report build progress to Dev Updater Counts Gradle tasks: --dry-run gives the total, the build gives one '> Task :x' line each as it goes. Gradle offers no direct route -- an init script using taskGraph.afterTask is rejected by the configuration cache, and whenReady never fires on a cache hit. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01QQz6R4kBQcWSHBNZMgBnjL --- app/build-apk.sh | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/app/build-apk.sh b/app/build-apk.sh index 4f9efc7..eae66a9 100755 --- a/app/build-apk.sh +++ b/app/build-apk.sh @@ -55,8 +55,41 @@ else exit 1 fi +# Dev Updater draws a real progress bar from "@@progress done/total" lines, +# and ignores anything that isn't exactly that shape. Gradle can't be asked +# for this directly: an init script using taskGraph.afterTask is rejected +# outright by the configuration cache, and whenReady never fires on a cache +# hit. --dry-run costs about a second, is cache-friendly, and prints one +# ":task SKIPPED" line per task the real build will run, which is exactly +# the total. The build then prints one "> Task :x" line per task as it +# goes, so counting those against it is the whole mechanism. +# +# Task count is not time -- compileDebugKotlin and dexBuilder are most of +# the wall clock -- so the bar moves unevenly. It is still counted work +# rather than a guess at how long last time took. +TASKS=$(./gradlew :androidApp:assembleDebug --dry-run --console=plain 2>/dev/null \ + | grep -c '^:[A-Za-z:]* SKIPPED' || true) + echo "==> Building" -./gradlew :androidApp:assembleDebug +if [ "${TASKS:-0}" -gt 0 ]; then + echo "@@progress 0/$TASKS" + DONE=0 + ./gradlew :androidApp:assembleDebug --console=plain 2>&1 | while IFS= read -r line; do + echo "$line" + case "$line" in + "> Task "*) + DONE=$((DONE + 1)) + echo "@@progress $DONE/$TASKS" + ;; + esac + done + # The pipeline's exit status is the shell's, not gradle's, so ask + # gradle again rather than reporting a failed build as a success. It is + # up to date by now, so this is a second or two. + ./gradlew :androidApp:assembleDebug --console=plain >/dev/null +else + ./gradlew :androidApp:assembleDebug +fi APK="$SCRIPT_DIR/androidApp/build/outputs/apk/debug/androidApp-debug.apk" echo