Skip to content

Commit bb30edf

Browse files
vlsiclaude
andcommitted
ci: map JDK vendor tokens to JvmVendorSpec constants
The CI matrix passes a short vendor token such as "eclipse" for the test JDK toolchain. JvmVendorSpec.matching("eclipse") probes the runtime java.vendor, which Temurin reports inconsistently across versions: JDK 8 reports "Temurin" while 11+ report "Eclipse Adoptium". A plain substring match therefore cannot resolve a Temurin 8 toolchain, and the same gap exists for any distribution whose vendor string differs from its token. Map the known tokens to Gradle's built-in JvmVendorSpec constants, which recognise every alias a distribution reports, and fall back to a substring match for anything unmapped. Also guard against a blank vendor so an empty token no longer narrows the toolchain query. Mirrors pgjdbc/pgjdbc#4257, which shares this build-logic file. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a82fa09 commit bb30edf

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

build-logic/basics/src/main/kotlin/configureToolchain.kt

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,27 @@ fun JavaToolchainSpec.configureToolchain(jdk: ToolchainProperties?) {
3232
return
3333
}
3434
languageVersion.set(JavaLanguageVersion.of(jdk.version))
35-
jdk.vendor?.let {
36-
vendor.set(JvmVendorSpec.matching(it))
35+
jdk.vendor?.takeIf { it.isNotBlank() }?.let {
36+
vendor.set(jvmVendorSpecFor(it))
3737
}
3838
if (jdk.implementation.equals("J9", ignoreCase = true)) {
3939
implementation.set(JvmImplementation.J9)
4040
}
4141
}
42+
43+
// The CI matrix passes a short vendor token such as "eclipse". Map the known ones to Gradle's
44+
// built-in JvmVendorSpec constants, which recognise every alias a distribution reports across
45+
// versions; fall back to a substring match for anything unmapped. This matters for Temurin:
46+
// JDK 8 reports java.vendor="Temurin" while 11+ report "Eclipse Adoptium", so a plain
47+
// matching("eclipse") cannot resolve a Temurin 8 toolchain (JvmVendorSpec.matching probes the
48+
// runtime java.vendor, not the IMPLEMENTOR field of the release file).
49+
private fun jvmVendorSpecFor(vendor: String): JvmVendorSpec =
50+
when (vendor.lowercase()) {
51+
"eclipse", "adoptium", "temurin" -> JvmVendorSpec.ADOPTIUM
52+
"amazon", "corretto" -> JvmVendorSpec.AMAZON
53+
"azul", "zulu" -> JvmVendorSpec.AZUL
54+
"bellsoft", "liberica" -> JvmVendorSpec.BELLSOFT
55+
"microsoft" -> JvmVendorSpec.MICROSOFT
56+
"oracle" -> JvmVendorSpec.ORACLE
57+
else -> JvmVendorSpec.matching(vendor)
58+
}

0 commit comments

Comments
 (0)