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) + }