From 7a4ea1b668b14ae53feff28cbcdf74a1f6724f52 Mon Sep 17 00:00:00 2001 From: Vladimir Sitnikov Date: Fri, 26 Jun 2026 00:02:25 +0300 Subject: [PATCH] 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 --- .../src/main/kotlin/configureToolchain.kt | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/build-logic/basics/src/main/kotlin/configureToolchain.kt b/build-logic/basics/src/main/kotlin/configureToolchain.kt index d797e7c4d6c..3c29af8e047 100644 --- a/build-logic/basics/src/main/kotlin/configureToolchain.kt +++ b/build-logic/basics/src/main/kotlin/configureToolchain.kt @@ -32,10 +32,27 @@ fun JavaToolchainSpec.configureToolchain(jdk: ToolchainProperties?) { return } languageVersion.set(JavaLanguageVersion.of(jdk.version)) - jdk.vendor?.let { - vendor.set(JvmVendorSpec.matching(it)) + jdk.vendor?.takeIf { it.isNotBlank() }?.let { + vendor.set(jvmVendorSpecFor(it)) } if (jdk.implementation.equals("J9", ignoreCase = true)) { implementation.set(JvmImplementation.J9) } } + +// The CI matrix passes a short vendor token such as "eclipse". Map the known ones to Gradle's +// built-in JvmVendorSpec constants, which recognise every alias a distribution reports across +// versions; fall back to a substring match for anything unmapped. This matters for Temurin: +// JDK 8 reports java.vendor="Temurin" while 11+ report "Eclipse Adoptium", so a plain +// matching("eclipse") cannot resolve a Temurin 8 toolchain (JvmVendorSpec.matching probes the +// runtime java.vendor, not the IMPLEMENTOR field of the release file). +private fun jvmVendorSpecFor(vendor: String): JvmVendorSpec = + when (vendor.lowercase()) { + "eclipse", "adoptium", "temurin" -> JvmVendorSpec.ADOPTIUM + "amazon", "corretto" -> JvmVendorSpec.AMAZON + "azul", "zulu" -> JvmVendorSpec.AZUL + "bellsoft", "liberica" -> JvmVendorSpec.BELLSOFT + "microsoft" -> JvmVendorSpec.MICROSOFT + "oracle" -> JvmVendorSpec.ORACLE + else -> JvmVendorSpec.matching(vendor) + }