mirror of
https://github.com/actions/runner-images.git
synced 2025-12-14 13:17:54 +00:00
[Windows] Add JAVA section to docs. (#2467)
* [macOS] Fail Pester tests on error * return it back * git pus * added fix for java docs * changed java place
This commit is contained in:
30
images/win/scripts/SoftwareReport/SoftwareReport.Java.psm1
Normal file
30
images/win/scripts/SoftwareReport/SoftwareReport.Java.psm1
Normal file
@@ -0,0 +1,30 @@
|
||||
function Get-JavaFullVersion {
|
||||
param($JavaRootPath)
|
||||
|
||||
$javaBinPath = Join-Path "$javaRootPath" "/bin/java"
|
||||
$javaVersionOutput = (Get-CommandResult "`"$javaBinPath`" -version").Output
|
||||
$matchResult = $javaVersionOutput | Select-String '^openjdk version \"([\d\._]+)\"'
|
||||
return $matchResult.Matches.Groups[1].Value
|
||||
}
|
||||
|
||||
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
|
||||
$version = Get-JavaFullVersion "$javaPath"
|
||||
$vendor = $version.StartsWith("1.7") ? "Zulu" : "AdoptOpenJDK"
|
||||
$defaultPostfix = ($javaPath -eq $defaultJavaPath) ? " (default)" : ""
|
||||
|
||||
[PSCustomObject] @{
|
||||
"Version" = $version + $defaultPostfix
|
||||
"Vendor" = $vendor
|
||||
"Environment Variable" = $_.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user