Files
runner-images/images/macos/scripts/docs-gen/SoftwareReport.Java.psm1
T

29 lines
890 B
PowerShell
Raw Normal View History

2020-09-10 14:34:08 +03:00
function Get-JavaVersions {
$defaultJavaPath = (Get-Item env:JAVA_HOME).value
2023-12-04 12:13:08 +01:00
$os = Get-OSVersion
2024-09-03 18:45:06 +02:00
if ($os.IsVenturaArm64 -or $os.IsSonomaArm64 -or $os.IsSequoiaArm64) {
$javaVersions = Get-Item env:JAVA_HOME_*_arm64
} else {
$javaVersions = Get-Item env:JAVA_HOME_*_X64
}
2023-12-04 12:13:08 +01:00
2020-09-10 14:34:08 +03:00
$sortRules = @{
2023-12-04 12:13:08 +01:00
Expression = { [Int32]$_.Name.Split("_")[2] }
2020-09-10 14:34:08 +03:00
Descending = $false
}
return $javaVersions | Sort-Object $sortRules | ForEach-Object {
$javaPath = $_.Value
# Take semver from the java path
$version = $javaPath.split('/')[5]
2021-03-27 10:51:01 +03:00
$fullVersion = $version.Replace('-', '+')
2020-09-10 14:34:08 +03:00
$defaultPostfix = ($javaPath -eq $defaultJavaPath) ? " (default)" : ""
[PSCustomObject] @{
2023-08-03 10:42:41 +02:00
"Version" = $fullVersion + $defaultPostfix
2020-09-10 14:34:08 +03:00
"Environment Variable" = $_.Name
}
}
}