Skip to content

Commit c200b12

Browse files
committed
Route CI Maven resolution through Databricks proxy
Maven Central is blocked on Databricks network (including GH Actions runners). Add proxy mirror config to all CI workflows so dependency resolution goes through maven-proxy.dev.databricks.com. For the release workflow, a Python script injects the mirror into the settings.xml that setup-java creates (to preserve server credentials). Co-authored-by: Isaac
1 parent 5be1ea0 commit c200b12

File tree

4 files changed

+68
-1
lines changed

4 files changed

+68
-1
lines changed

.github/inject-maven-mirror.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"""Inject Databricks Maven proxy mirror into an existing settings.xml.
2+
3+
If no settings.xml exists at the given path, copies the default from
4+
.github/maven-settings.xml instead.
5+
"""
6+
import sys
7+
import xml.etree.ElementTree as ET
8+
from pathlib import Path
9+
10+
MIRROR_XML = """\
11+
<mirror>
12+
<id>databricks-maven-proxy</id>
13+
<mirrorOf>central</mirrorOf>
14+
<url>https://maven-proxy.dev.databricks.com</url>
15+
</mirror>"""
16+
17+
settings_path = Path(sys.argv[1])
18+
19+
if not settings_path.exists():
20+
# No existing settings, just copy the default
21+
default = Path(__file__).parent / "maven-settings.xml"
22+
settings_path.parent.mkdir(parents=True, exist_ok=True)
23+
settings_path.write_text(default.read_text())
24+
print(f"Copied default maven-settings.xml to {settings_path}")
25+
sys.exit(0)
26+
27+
# Parse existing settings and inject mirror
28+
tree = ET.parse(settings_path)
29+
root = tree.getroot()
30+
31+
# Handle Maven namespace
32+
ns = ""
33+
if root.tag.startswith("{"):
34+
ns = root.tag.split("}")[0] + "}"
35+
36+
mirrors = root.find(f"{ns}mirrors")
37+
if mirrors is None:
38+
mirrors = ET.SubElement(root, "mirrors")
39+
40+
mirror = ET.SubElement(mirrors, "mirror")
41+
ET.SubElement(mirror, "id").text = "databricks-maven-proxy"
42+
ET.SubElement(mirror, "mirrorOf").text = "central"
43+
ET.SubElement(mirror, "url").text = "https://maven-proxy.dev.databricks.com"
44+
45+
tree.write(settings_path, xml_declaration=True, encoding="UTF-8")
46+
print(f"Injected Maven proxy mirror into {settings_path}")

.github/maven-settings.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<settings>
2+
<mirrors>
3+
<mirror>
4+
<id>databricks-maven-proxy</id>
5+
<mirrorOf>central</mirrorOf>
6+
<url>https://maven-proxy.dev.databricks.com</url>
7+
</mirror>
8+
</mirrors>
9+
</settings>

.github/workflows/push.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ jobs:
1818
- name: Checkout
1919
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
2020

21+
- name: Configure Maven proxy
22+
run: mkdir -p ~/.m2 && cp .github/maven-settings.xml ~/.m2/settings.xml
23+
2124
- name: Cache Maven packages
2225
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
2326
with:
@@ -46,6 +49,9 @@ jobs:
4649
- name: Checkout
4750
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
4851

52+
- name: Configure Maven proxy
53+
run: mkdir -p ~/.m2 && cp .github/maven-settings.xml ~/.m2/settings.xml
54+
4955
- name: Cache Maven packages
5056
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
5157
with:
@@ -67,5 +73,8 @@ jobs:
6773
- name: Checkout
6874
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
6975

76+
- name: Configure Maven proxy
77+
run: mkdir -p ~/.m2 && cp .github/maven-settings.xml ~/.m2/settings.xml
78+
7079
- name: Validate lockfile
7180
run: make check-lock

.github/workflows/release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ jobs:
3232
server-password: MAVEN_CENTRAL_PASSWORD
3333
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
3434
gpg-passphrase: GPG_PASSPHRASE
35-
35+
36+
- name: Configure Maven proxy
37+
run: python3 .github/inject-maven-mirror.py ~/.m2/settings.xml
38+
3639
# This step runs ONLY on branch pushes (dry-run)
3740
- name: Run Release Dry-Run (Verify)
3841
if: "!startsWith(github.ref, 'refs/tags/')"

0 commit comments

Comments
 (0)