Skip to content

Commit a00b908

Browse files
gopalldbclaude
andauthored
Fix: normalize _remote.repositories repo ID for offline mode (#1393)
## Summary Deleting _remote.repositories was not enough — Maven 3.9+ still refused cached artifacts in offline mode with "has not been downloaded from it before". The root cause: Maven checks that the artifact was downloaded from "central" but the _remote.repositories files referenced "jfrog-central" (the warmer mirror ID). Fix: in the warmer, sed-replace "jfrog-central" with "central" in all _remote.repositories files before saving the cache. This makes Maven offline mode accept cached artifacts as coming from "central" (the default repo ID). Verified locally: ALL 5 CI commands pass with replaced repo IDs + offline mode: - spotless:check → BUILD SUCCESS - unit tests → BUILD SUCCESS - jacoco:report → BUILD SUCCESS - packaging install → BUILD SUCCESS - test-compile → BUILD SUCCESS ## After merge 1. Delete stale cache entries 2. Trigger cache warmer 3. Re-run PR #1371 CI NO_CHANGELOG=true This pull request was AI-assisted by Isaac. --------- Signed-off-by: Gopal Lal <gopal.lal@databricks.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5cd14cb commit a00b908

2 files changed

Lines changed: 14 additions & 19 deletions

File tree

.github/actions/setup-maven/action.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,10 @@ runs:
2727
run: |
2828
mkdir -p ~/.m2
2929
30-
# Remove _remote.repositories marker files. These track which remote
31-
# repo each artifact came from. Without them, Maven treats all cached
32-
# artifacts as locally installed and resolves them without contacting
33-
# any remote server.
34-
find ~/.m2/repository -name '_remote.repositories' -delete 2>/dev/null || true
35-
echo "Removed _remote.repositories markers from cache"
36-
37-
# Enable Maven offline mode via .mvn/maven.config. This file is read
38-
# automatically by Maven as default CLI arguments. Offline mode prevents
30+
# Enable Maven offline mode via .mvn/maven.config. Offline mode prevents
3931
# all network requests — no JFrog auth needed, no Maven Central fallback.
40-
# Combined with _remote.repositories removal, Maven resolves everything
41-
# from the local cache.
32+
# The cache warmer normalizes _remote.repositories to use 'central' as the
33+
# repo ID, so offline mode accepts all cached artifacts.
4234
mkdir -p .mvn
4335
echo "-o" >> .mvn/maven.config
4436
echo "Maven offline mode enabled via .mvn/maven.config"
@@ -48,7 +40,7 @@ runs:
4840
<settings />
4941
SETTINGS_EOF
5042
51-
echo "Maven configured for forked PR (cache-only, no remote access)"
43+
echo "Maven configured for forked PR (offline mode, cache-only)"
5244
5345
# --- Same-repo path: full JFrog OIDC authentication ---
5446
- name: Get JFrog OIDC token

.github/workflows/warmMavenCache.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,18 @@ jobs:
160160
161161
echo "Dependency resolution complete"
162162
163-
- name: Remove _remote.repositories before saving cache
163+
- name: Normalize _remote.repositories before saving cache
164164
shell: bash
165165
run: |
166-
# Remove _remote.repositories marker files before saving. These track
167-
# which remote repo ID each artifact was downloaded from (jfrog-central).
168-
# Without them, forked PRs can use the cache in offline mode without
169-
# Maven complaining about repo ID mismatches.
170-
COUNT=$(find ~/.m2/repository -name '_remote.repositories' -delete -print | wc -l)
171-
echo "Removed ${COUNT} _remote.repositories markers"
166+
# Replace 'jfrog-central' with 'central' in _remote.repositories files.
167+
# These files track which repo ID each artifact was downloaded from. The
168+
# cache warmer downloads from 'jfrog-central' (the JFrog mirror), but
169+
# Maven's offline mode expects artifacts to be associated with 'central'
170+
# (the default Maven Central repo ID). Without this, offline mode refuses
171+
# cached artifacts with "has not been downloaded from it before".
172+
COUNT=$(find ~/.m2/repository -name '_remote.repositories' -print | wc -l)
173+
find ~/.m2/repository -name '_remote.repositories' -exec sed -i 's/jfrog-central/central/g' {} \;
174+
echo "Normalized ${COUNT} _remote.repositories markers (jfrog-central -> central)"
172175
173176
- name: Save Maven dependency cache
174177
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4

0 commit comments

Comments
 (0)