Files
runner-images/images/macos/software-report/SoftwareReport.Java.psm1
T

23 lines
832 B
PowerShell
Raw Normal View History

2020-09-10 14:34:08 +03:00
function Get-JavaVersions {
$defaultJavaPath = (Get-Item env:JAVA_HOME).value
2020-09-10 14:34:08 +03:00
$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]
2021-03-27 10:51:01 +03:00
$fullVersion = $version.Replace('-', '+')
2020-09-10 14:34:08 +03:00
$defaultPostfix = ($javaPath -eq $defaultJavaPath) ? " (default)" : ""
$vendorName = ($javaPath -like '*Java_Adopt_jdk*') ? "Adopt OpenJDK" : "Eclipse Temurin"
2020-09-10 14:34:08 +03:00
[PSCustomObject] @{
2021-03-27 10:51:01 +03:00
"Version" = $fullVersion + $defaultPostfix
"Vendor" = $vendorName
2020-09-10 14:34:08 +03:00
"Environment Variable" = $_.Name
}
}
}