mirror of
https://github.com/actions/runner-images.git
synced 2025-12-15 06:08:07 +00:00
23 lines
832 B
PowerShell
23 lines
832 B
PowerShell
function Get-JavaVersions {
|
|
$defaultJavaPath = (Get-Item env:JAVA_HOME).value
|
|
$javaVersions = Get-Item env:JAVA_HOME_*_X64
|
|
$sortRules = @{
|
|
Expression = { [Int32]$_.Name.Split("_")[2] }
|
|
Descending = $false
|
|
}
|
|
|
|
return $javaVersions | Sort-Object $sortRules | ForEach-Object {
|
|
$javaPath = $_.Value
|
|
# Take semver from the java path
|
|
$version = $javaPath.split('/')[5]
|
|
$fullVersion = $version.Replace('-', '+')
|
|
$defaultPostfix = ($javaPath -eq $defaultJavaPath) ? " (default)" : ""
|
|
$vendorName = ($javaPath -like '*Java_Adopt_jdk*') ? "Adopt OpenJDK" : "Eclipse Temurin"
|
|
|
|
[PSCustomObject] @{
|
|
"Version" = $fullVersion + $defaultPostfix
|
|
"Vendor" = $vendorName
|
|
"Environment Variable" = $_.Name
|
|
}
|
|
}
|
|
} |