androidx_incremental zipping kotlin metadata on failure

Bug: 188565600
Test: ./busytown/androidx.sh misspelled; ls ../../out/incremental/kotlinMetadata.zip

Change-Id: Ia85ed7eaaf5fb9fbe3dc75d92f1c607374bf70bc
diff --git a/busytown/androidx_incremental.sh b/busytown/androidx_incremental.sh
index b5d5079..2c3383c1 100755
--- a/busytown/androidx_incremental.sh
+++ b/busytown/androidx_incremental.sh
@@ -29,9 +29,22 @@
 }
 hashOutDir
 
+# diagnostics to hopefully help us figure out b/188565660
+function zipKotlinMetadata() {
+  zipFile=kotlinMetadata.zip
+  echo "zipping kotlin metadata"
+  (cd $OUT_DIR && find -name "*kotlin_metadata" | xargs zip "$DIST_DIR/$zipFile")
+  echo done zipping kotlin metadata
+}
+
 # Run Gradle
-impl/build.sh buildOnServer checkExternalLicenses listTaskOutputs validateAllProperties \
-    --profile "$@"
+if impl/build.sh buildOnServer checkExternalLicenses listTaskOutputs validateAllProperties \
+    --profile "$@"; then
+  echo build succeeded
+else
+  zipKotlinMetadata
+  echo build failed
+fi
 
 # Parse performance profile reports (generated with the --profile option above) and re-export the metrics in an easily machine-readable format for tracking
 impl/parse_profile_htmls.sh