Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions build-logic/basics/src/main/kotlin/configureToolchain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Loading