From 70f768e60502569409e66bad08139ae5cc3df888 Mon Sep 17 00:00:00 2001 From: Satyaki Ghosh Date: Mon, 13 Jul 2026 16:15:53 -0400 Subject: [PATCH] Add logging for java build --- .github/workflows/release.yml | 10 +++++++++- src/bindings-jvm/build.sh | 16 +++++++++++++++- src/bindings-jvm/merge-jars.sh | 8 ++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e328d29..7a59bda 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -264,7 +264,15 @@ jobs: exit 1 fi done - echo "Committed jar carries all three platform natives." + if ! unzip -Z1 "$jar" | grep -q '\.class$'; then + echo "::error::committed jar contains no compiled .class output; the JVM build did not compile" + exit 1 + fi + if ! unzip -Z1 "$jar" | grep -q '\.kt$'; then + echo "::error::committed jar contains no .kt sources; the source bundling step did not run" + exit 1 + fi + echo "Committed jar carries all three platform natives plus compiled classes and sources." - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v6.2.0 diff --git a/src/bindings-jvm/build.sh b/src/bindings-jvm/build.sh index 16dc336..6a48163 100755 --- a/src/bindings-jvm/build.sh +++ b/src/bindings-jvm/build.sh @@ -114,6 +114,19 @@ EOF echo "Compiling and packaging JAR via Gradle..." gradle --no-daemon --console=plain jar +# ── Verify the JAR carries compiled classes and sources ────────────────────── +# A jar that bundles the .kt sources but not the compiled .class output (e.g. a +# Gradle source-set regression that drops the compilation output) still packages, +# uploads, and publishes successfully, then fails every consumer at class-load time. +# Assert both are present so that failure surfaces here rather than downstream. +# There are no .java entries by design — the bindings are Kotlin-only. +CLASS_COUNT=$(jar tf "$JAR_FILE" | grep -c '\.class$' || true) +KT_COUNT=$(jar tf "$JAR_FILE" | grep -c '\.kt$' || true) +if [ "$CLASS_COUNT" -eq 0 ] || [ "$KT_COUNT" -eq 0 ]; then + echo "Error: $JAR_FILE is missing compiled output — $CLASS_COUNT .class and $KT_COUNT .kt entries (both must be non-zero)." >&2 + exit 1 +fi + # ── Summary ─────────────────────────────────────────────────────────────────── KT_SIZE=$(find "$GENERATED_DIR" -name '*.kt' -type f -exec cat {} + | wc -c | awk '{printf "%.1fM", $1/1048576}') LIB_SIZE=$(du -sh "$RELEASE_DIR/$LIB_NAME" | cut -f1) @@ -121,7 +134,8 @@ JAR_SIZE=$(du -sh "$JAR_FILE" | cut -f1) echo "" echo "Build complete: $GENERATED_DIR" -echo " Kotlin sources: $KT_SIZE" +echo " Kotlin sources: $KT_SIZE ($KT_COUNT .kt files bundled)" +echo " Compiled classes: $CLASS_COUNT .class entries bundled" echo " Native library: $LIB_SIZE ($LIB_NAME, bundled in jar)" echo " JAR: $JAR_SIZE ($(basename "$JAR_FILE"))" echo "" diff --git a/src/bindings-jvm/merge-jars.sh b/src/bindings-jvm/merge-jars.sh index 1c4d14b..2cdc4f5 100755 --- a/src/bindings-jvm/merge-jars.sh +++ b/src/bindings-jvm/merge-jars.sh @@ -15,6 +15,14 @@ OUT_JAR="$OUT_DIR/$(basename "$OUT_JAR")" BASE_JAR="$1"; shift echo "Base jar (classes + sources + native): $BASE_JAR" + +base_classes="$(unzip -Z1 "$BASE_JAR" | grep -c '\.class$' || true)" +base_sources="$(unzip -Z1 "$BASE_JAR" | grep -c '\.kt$' || true)" +if [ "$base_classes" -eq 0 ] || [ "$base_sources" -eq 0 ]; then + echo "Error: base jar $BASE_JAR is missing compiled output — $base_classes .class and $base_sources .kt entries (both must be non-zero)." >&2 + exit 1 +fi + cp "$BASE_JAR" "$OUT_JAR" for jar_file in "$@"; do