Files
runner-images/images/win/scripts/SoftwareReport/SoftwareReport.Java.psm1
Mikhail Timofeev 0cf21e4512 [Windows] Move preinstalled java distributions to the toolcache directory (#2903)
* Move installation to toolcache folder

* Change Set-JavaPath function

* remove old java report function

* Change report function to output full semver

* small improvments

* nitpicks + remove java root path

* Adoptium -> Adopt
2021-03-16 17:16:16 +03:00

21 lines
687 B
PowerShell

function Get-JavaVersions {
$defaultJavaPath = $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 = (Split-Path $javaPath) -replace "\w:\\.*\\"
$defaultPostfix = ($javaPath -eq $defaultJavaPath) ? " (default)" : ""
[PSCustomObject] @{
"Version" = $version + $defaultPostfix
"Vendor" = "AdoptOpenJDK"
"Environment Variable" = $_.Name
}
}
}