@@ -436,4 +436,79 @@ jobs:
436436 uses : googleapis/java-cloud-bom/tests/validate-bom@377c8d1fac6b1521dc52a10f4d02e5d371a0de67 # v26.79.0
437437 with :
438438 bom-path : gapic-libraries-bom/pom.xml
439+ test-cache-overwrite :
440+ name : verify-cache-overwrite
441+ runs-on : ubuntu-latest
442+ steps :
443+ - uses : actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
444+ with :
445+ persist-credentials : false
446+ - uses : actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0
447+ with :
448+ distribution : temurin
449+ java-version : 17
450+ cache : maven
451+ - name : 1. Inspect Initial Restored .m2 Cache State
452+ run : |
453+ echo "============================================================"
454+ echo "Checking initial state of ~/.m2/repository from cache..."
455+ echo "============================================================"
456+ if [ -d "$HOME/.m2/repository" ]; then
457+ echo "Cache Restored! ~/.m2/repository directory size:"
458+ du -sh "$HOME/.m2/repository" || true
459+ echo "Sample existing dependencies in ~/.m2/repository:"
460+ find "$HOME/.m2/repository" -maxdepth 3 -type d | head -n 20 || true
461+ else
462+ echo "No existing ~/.m2/repository found (first cold run for this cache key)."
463+ fi
464+ - name : 2. Build and Install Baseline Module to ~/.m2
465+ run : |
466+ echo "============================================================"
467+ echo "Building and installing java-common-protos to ~/.m2..."
468+ echo "============================================================"
469+ mvn install -Pquick-build -DskipTests=true -pl java-common-protos/proto-google-common-protos -am -B -ntp -T 1C
470+ ARTIFACT_DIR="$HOME/.m2/repository/com/google/api/grpc/proto-google-common-protos"
471+ echo "Baseline files in $ARTIFACT_DIR:"
472+ find "$ARTIFACT_DIR" -type f -exec ls -la {} +
473+ - name : 3. Simulate Code Change in Module & Re-install
474+ run : |
475+ echo "============================================================"
476+ echo "Modifying source file in java-common-protos to create a new version..."
477+ echo "============================================================"
478+ MARKER_FILE="java-common-protos/proto-google-common-protos/src/main/java/com/google/type/CacheTestMarker.java"
479+ mkdir -p "$(dirname "$MARKER_FILE")"
480+ TIMESTAMP=$(date +%s)
481+ cat <<EOF > "$MARKER_FILE"
482+ package com.google.type;
483+
484+ public class CacheTestMarker {
485+ public static final String TIMESTAMP = "$TIMESTAMP";
486+ public static final String VERSION_MARKER = "TEST_CACHE_OVERWRITE_VERIFIED_$TIMESTAMP";
487+ }
488+ EOF
489+ echo "Created source marker:"
490+ cat "$MARKER_FILE"
491+ echo "Recording pre-install artifact timestamps and checksums in ~/.m2..."
492+ find "$HOME/.m2/repository/com/google/api/grpc/proto-google-common-protos" -name "*.jar" -exec sha256sum {} + || true
493+
494+ echo "Re-installing modified module..."
495+ mvn install -Pquick-build -DskipTests=true -pl java-common-protos/proto-google-common-protos -B -ntp -T 1C
496+ - name : 4. Verify & Print Overwrite in Runner .m2
497+ run : |
498+ echo "============================================================"
499+ echo "Verifying newly built version physically overwrote ~/.m2..."
500+ echo "============================================================"
501+ ARTIFACT_DIR="$HOME/.m2/repository/com/google/api/grpc/proto-google-common-protos"
502+ echo "Files in $ARTIFACT_DIR after re-install:"
503+ find "$ARTIFACT_DIR" -type f -exec ls -la {} +
504+
505+ echo "New JAR SHA256 checksums in ~/.m2:"
506+ find "$ARTIFACT_DIR" -name "*.jar" -exec sha256sum {} +
507+
508+ echo "Extracting and verifying CacheTestMarker class inside ~/.m2 jar:"
509+ JAR_FILE=$(find "$ARTIFACT_DIR" -name "proto-google-common-protos-*.jar" ! -name "*-sources.jar" ! -name "*-tests.jar" | head -n 1)
510+ echo "Checking JAR: $JAR_FILE"
511+ jar tf "$JAR_FILE" | grep "CacheTestMarker" || { echo "ERROR: Marker class not found in installed JAR!"; exit 1; }
512+
513+ echo "SUCCESS: The local module was freshly compiled and overwritten in ~/.m2/repository!"
439514
0 commit comments