Files
runner-images/images/macos/software-report/SoftwareReport.Java.psm1
Nikita Bykov ef6e8c905f [MacOS] Move preinstalled java distributions to the toolcache directory (#2883)
* Move java to the toolcache

* resolved comments

* added sudo for ln command

* fixed versions and added symlink

* fixed openjdk.sh

* fixed typo

* updated SoftwareReport

* fixed SoftwareReport

* fixed SoftwareReport

* fixed tool name

Co-authored-by: Nikita Bykov <v-nibyko@microsoft.com>
2021-03-16 17:13:54 +03:00

21 lines
676 B
PowerShell

function Get-JavaVersions {
$defaultJavaPath = Get-Item env:JAVA_HOME
$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]
$defaultPostfix = ($javaPath -eq $defaultJavaPath) ? " (default)" : ""
[PSCustomObject] @{
"Version" = $version + $defaultPostfix
"Vendor" = "Adopt OpenJDK"
"Environment Variable" = $_.Name
}
}
}