From 72fa7094d06f7f19fd7ba343a40ac89e092020de Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Wed, 1 Jul 2026 22:30:08 +0000 Subject: [PATCH 1/5] fix(ci): check local cache before Maven Central in reachability test Modify BomContentTest to check if an artifact exists in the local Maven repository (.m2) before checking its reachability on Maven Central. During release PRs, new versions of libraries are built and installed locally (via pre-install.sh) but are not yet published to Maven Central. This change allows the reachability check to pass for these new versions if they are found in the local cache, while still verifying that other dependencies (which should be on Central) are reachable. This removes the need for conditional flags in GHA workflows. --- .../java/com/google/cloud/BomContentTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java b/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java index 5db40f69f0f1..ce9f5a53ae79 100644 --- a/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java +++ b/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java @@ -30,6 +30,7 @@ import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -76,6 +77,9 @@ private void checkBom(Path bomPath) throws Exception { if (artifact.getVersion().contains("SNAPSHOT")) { continue; } + if (existsLocally(artifact)) { + continue; + } assertReachable(buildMavenCentralUrl(artifact)); } @@ -104,6 +108,9 @@ static void checkBomReachable(Path bomPath) throws Exception { if (artifact.getVersion().contains("SNAPSHOT")) { continue; } + if (existsLocally(artifact)) { + continue; + } try { assertReachable(buildMavenCentralUrl(artifact)); } catch (IOException ex) { @@ -134,6 +141,19 @@ private static String buildMavenCentralUrl(Artifact artifact) { + ".pom"; } + private static boolean existsLocally(Artifact artifact) { + String localRepository = System.getProperty("maven.repo.local"); + if (localRepository == null) { + localRepository = System.getProperty("user.home") + "/.m2/repository"; + } + Path localPath = Paths.get(localRepository, + artifact.getGroupId().replace('.', '/'), + artifact.getArtifactId(), + artifact.getVersion(), + artifact.getArtifactId() + "-" + artifact.getVersion() + ".pom"); + return Files.exists(localPath); + } + /** Asserts that the BOM only provides JARs which contains unique class names to the classpath. */ private static void assertUniqueClasses(List allArtifacts) throws InvalidVersionSpecificationException, IOException { From a42c139ef901034349093e53f6d510baa5d9bfab Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Wed, 1 Jul 2026 22:47:18 +0000 Subject: [PATCH 2/5] chore: add comments explaining local cache reachability bypass --- .../test/java/com/google/cloud/BomContentTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java b/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java index ce9f5a53ae79..18868177d879 100644 --- a/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java +++ b/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java @@ -77,6 +77,9 @@ private void checkBom(Path bomPath) throws Exception { if (artifact.getVersion().contains("SNAPSHOT")) { continue; } + // If the artifact is built locally (e.g. during a release PR), it will be in the local + // .m2 cache. We can skip checking Maven Central for these local artifacts since they + // are not yet published. if (existsLocally(artifact)) { continue; } @@ -108,6 +111,9 @@ static void checkBomReachable(Path bomPath) throws Exception { if (artifact.getVersion().contains("SNAPSHOT")) { continue; } + // If the artifact is built locally (e.g. during a release PR), it will be in the local + // .m2 cache. We can skip checking Maven Central for these local artifacts since they + // are not yet published. if (existsLocally(artifact)) { continue; } @@ -141,9 +147,15 @@ private static String buildMavenCentralUrl(Artifact artifact) { + ".pom"; } + /** + * Checks if the artifact exists in the local Maven repository cache. + * This is used as a fallback/bypass for reachability checks during release PRs. + */ private static boolean existsLocally(Artifact artifact) { String localRepository = System.getProperty("maven.repo.local"); if (localRepository == null) { + // Standard default location for Maven local repository. + // GHA runners also use this path by default (cached by actions/setup-java). localRepository = System.getProperty("user.home") + "/.m2/repository"; } Path localPath = Paths.get(localRepository, From dbfef3fa1c62b5654bb6c4d67c966e78eb58d22c Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Wed, 1 Jul 2026 22:49:00 +0000 Subject: [PATCH 3/5] chore: refine comment, remove GHA runner reference --- .../tests/src/test/java/com/google/cloud/BomContentTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java b/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java index 18868177d879..b33a2f7237ac 100644 --- a/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java +++ b/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java @@ -155,7 +155,6 @@ private static boolean existsLocally(Artifact artifact) { String localRepository = System.getProperty("maven.repo.local"); if (localRepository == null) { // Standard default location for Maven local repository. - // GHA runners also use this path by default (cached by actions/setup-java). localRepository = System.getProperty("user.home") + "/.m2/repository"; } Path localPath = Paths.get(localRepository, From 8fd4ac052d2442447287f0f69db7e21cdd1b21a2 Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Mon, 6 Jul 2026 14:55:04 +0000 Subject: [PATCH 4/5] chore: format BomContentTest.java --- .../java/com/google/cloud/BomContentTest.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java b/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java index b33a2f7237ac..25aba5bf5765 100644 --- a/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java +++ b/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java @@ -148,8 +148,8 @@ private static String buildMavenCentralUrl(Artifact artifact) { } /** - * Checks if the artifact exists in the local Maven repository cache. - * This is used as a fallback/bypass for reachability checks during release PRs. + * Checks if the artifact exists in the local Maven repository cache. This is used as a + * fallback/bypass for reachability checks during release PRs. */ private static boolean existsLocally(Artifact artifact) { String localRepository = System.getProperty("maven.repo.local"); @@ -157,11 +157,13 @@ private static boolean existsLocally(Artifact artifact) { // Standard default location for Maven local repository. localRepository = System.getProperty("user.home") + "/.m2/repository"; } - Path localPath = Paths.get(localRepository, - artifact.getGroupId().replace('.', '/'), - artifact.getArtifactId(), - artifact.getVersion(), - artifact.getArtifactId() + "-" + artifact.getVersion() + ".pom"); + Path localPath = + Paths.get( + localRepository, + artifact.getGroupId().replace('.', '/'), + artifact.getArtifactId(), + artifact.getVersion(), + artifact.getArtifactId() + "-" + artifact.getVersion() + ".pom"); return Files.exists(localPath); } From 3acf0253088be14cbdf0d11c6a030c4cd0a66384 Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Mon, 6 Jul 2026 14:56:42 +0000 Subject: [PATCH 5/5] fix(ci): handle null user.home defensively in BomContentTest --- .../src/test/java/com/google/cloud/BomContentTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java b/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java index 25aba5bf5765..94ec1219a185 100644 --- a/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java +++ b/java-cloud-bom/tests/src/test/java/com/google/cloud/BomContentTest.java @@ -154,8 +154,12 @@ private static String buildMavenCentralUrl(Artifact artifact) { private static boolean existsLocally(Artifact artifact) { String localRepository = System.getProperty("maven.repo.local"); if (localRepository == null) { + String userHome = System.getProperty("user.home"); + if (userHome == null) { + return false; + } // Standard default location for Maven local repository. - localRepository = System.getProperty("user.home") + "/.m2/repository"; + localRepository = userHome + "/.m2/repository"; } Path localPath = Paths.get(