|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Verifies sqlite-android-inspection: assemble, debug classpath, AAR SPI/classes. |
| 4 | +# Usage (from repo root): ./scripts/verify-sqlite-android-inspection.sh |
| 5 | +# Exit non-zero on any failure. |
| 6 | + |
| 7 | +set -euo pipefail |
| 8 | + |
| 9 | +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| 10 | +cd "$ROOT" |
| 11 | + |
| 12 | +echo "==> sqlite-android-inspection verification (repo: $ROOT)" |
| 13 | +echo |
| 14 | + |
| 15 | +echo "==> [1/5] Gradle assembleDebug" |
| 16 | +./gradlew :sqlite-android-inspection:assembleDebug --no-daemon -q |
| 17 | + |
| 18 | +echo "==> [2/5] Gradle assembleRelease" |
| 19 | +./gradlew :sqlite-android-inspection:assembleRelease --no-daemon -q |
| 20 | + |
| 21 | +echo "==> [3/5] debugCompileClasspath includes androidx.inspection:inspection" |
| 22 | +if ! ./gradlew :sqlite-android-inspection:dependencies --configuration debugCompileClasspath --no-daemon -q 2>/dev/null | grep -q 'androidx.inspection:inspection'; then |
| 23 | + echo "ERROR: androidx.inspection:inspection not found on debugCompileClasspath (check snapshot repo / androidx.inspection.snapshot.buildId)" >&2 |
| 24 | + exit 1 |
| 25 | +fi |
| 26 | + |
| 27 | +AAR_DIR="$ROOT/sqlite-android-inspection/build/outputs/aar" |
| 28 | +AAR="" |
| 29 | +if [[ -d "$AAR_DIR" ]]; then |
| 30 | + AAR=$(ls -1 "$AAR_DIR"/*-debug.aar 2>/dev/null | head -1 || true) |
| 31 | +fi |
| 32 | + |
| 33 | +if [[ -z "${AAR:-}" || ! -f "$AAR" ]]; then |
| 34 | + echo "ERROR: expected debug AAR under $AAR_DIR" >&2 |
| 35 | + exit 1 |
| 36 | +fi |
| 37 | +echo "==> [4/5] AAR: $AAR" |
| 38 | + |
| 39 | +TMP="$(mktemp -d)" |
| 40 | +trap 'rm -rf "$TMP"' EXIT |
| 41 | + |
| 42 | +unzip -q -o "$AAR" -d "$TMP" |
| 43 | + |
| 44 | +JAR="$TMP/classes.jar" |
| 45 | +if [[ ! -f "$JAR" ]]; then |
| 46 | + echo "ERROR: classes.jar missing in AAR" >&2 |
| 47 | + exit 1 |
| 48 | +fi |
| 49 | + |
| 50 | +SPI_REL="META-INF/services/androidx.inspection.InspectorFactory" |
| 51 | +if ! jar tf "$JAR" | grep -q "^${SPI_REL}\$"; then |
| 52 | + echo "ERROR: missing $SPI_REL in classes.jar" >&2 |
| 53 | + exit 1 |
| 54 | +fi |
| 55 | +SPI_CONTENT="$(unzip -p "$JAR" "$SPI_REL")" |
| 56 | +if ! grep -q 'androidx\.sqlite\.inspection\.SqliteInspectorFactory' <<<"$SPI_CONTENT"; then |
| 57 | + echo "ERROR: SPI factory line not found in $SPI_REL" >&2 |
| 58 | + printf '%s\n' "$SPI_CONTENT" >&2 |
| 59 | + exit 1 |
| 60 | +fi |
| 61 | +echo " SPI OK: $(echo "$SPI_CONTENT" | tr -d '\n')" |
| 62 | + |
| 63 | +for class in \ |
| 64 | + 'androidx/sqlite/inspection/SqliteInspector.class' \ |
| 65 | + 'androidx/sqlite/inspection/SqliteInspectorFactory.class'; do |
| 66 | + if ! jar tf "$JAR" | grep -q "^$class\$"; then |
| 67 | + echo "ERROR: missing $class in classes.jar" >&2 |
| 68 | + exit 1 |
| 69 | + fi |
| 70 | + echo " class OK: $class" |
| 71 | +done |
| 72 | + |
| 73 | +echo |
| 74 | +echo "==> [5/5] All checks passed. E2E: :sqlite-android-inspection:connectedDebugAndroidTest (see VENDOR.txt)." |
0 commit comments