Skip to content

Commit 8cdc57f

Browse files
committed
Fix Spring version source detection in generator
1 parent 4debc5f commit 8cdc57f

1 file changed

Lines changed: 36 additions & 5 deletions

File tree

sdk/spring/scripts/generate_spring_versions_and_pr_description.py

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
SPRING_BOOT_RELEASE_TAG_URL = "https://github.com/spring-projects/spring-boot/releases/tag/v{}"
1414
SPRING_BOOT_RELEASE_API_URL = "https://api.github.com/repos/spring-projects/spring-boot/releases/tags/v{}"
1515
EXTERNAL_DEPENDENCIES_FILE = "eng/versioning/external_dependencies.txt"
16+
SUPPORT_MATRIX_FILE = "sdk/spring/pipeline/spring-cloud-azure-supported-spring.json"
1617
SPRING_VERSIONS_OUTPUT = "spring-versions.txt"
1718
PR_DESCRIPTIONS_OUTPUT = "pr-descriptions.txt"
1819

@@ -59,17 +60,47 @@ def sort_versions_desc(versions):
5960

6061

6162
def read_current_supported_versions():
63+
# Prefer the support matrix because it reflects the current Spring compatibility target.
6264
boot = None
6365
cloud = None
66+
try:
67+
with open(SUPPORT_MATRIX_FILE, "r", encoding="utf-8") as f:
68+
entries = json.load(f)
69+
current_entries = [
70+
e for e in entries
71+
if e.get("current") and e.get("supportStatus") == "SUPPORTED"
72+
]
73+
if current_entries:
74+
current = current_entries[0]
75+
boot = current.get("spring-boot-version")
76+
cloud = current.get("spring-cloud-version")
77+
except (FileNotFoundError, json.JSONDecodeError, TypeError):
78+
pass
79+
80+
if boot and cloud:
81+
return boot, cloud
82+
83+
# Fallback to external dependencies for compatibility with older layouts.
84+
boot_candidates = {
85+
"org.springframework.boot:spring-boot-dependencies",
86+
"org.springframework.boot:spring-boot-starter-parent",
87+
"org.springframework.boot:spring-boot-starter",
88+
"org.springframework.boot:spring-boot-maven-plugin",
89+
}
6490
with open(EXTERNAL_DEPENDENCIES_FILE, "r", encoding="utf-8") as f:
6591
for line in f:
6692
line = line.strip()
67-
if line.startswith("org.springframework.boot:spring-boot-dependencies;"):
68-
boot = line.split(";", 1)[1]
69-
elif line.startswith("org.springframework.cloud:spring-cloud-dependencies;"):
70-
cloud = line.split(";", 1)[1]
93+
if not line or line.startswith("#") or ";" not in line:
94+
continue
95+
artifact, version = line.split(";", 1)
96+
if artifact in boot_candidates and not boot:
97+
boot = version
98+
elif artifact == "org.springframework.cloud:spring-cloud-dependencies" and not cloud:
99+
cloud = version
71100
if not boot or not cloud:
72-
raise RuntimeError("Failed to read current Spring Boot/Cloud versions from external_dependencies.txt")
101+
raise RuntimeError(
102+
"Failed to read current Spring Boot/Cloud versions from support matrix and external_dependencies.txt"
103+
)
73104
return boot, cloud
74105

75106

0 commit comments

Comments
 (0)