mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
[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
This commit is contained in:
@@ -13,30 +13,6 @@ function Get-BashVersion {
|
||||
return "Bash $version"
|
||||
}
|
||||
|
||||
function Get-JavaVersionsList {
|
||||
param(
|
||||
[string] $DefaultVersion
|
||||
)
|
||||
|
||||
$postfix = ""
|
||||
$javaDir = Join-Path $env:PROGRAMFILES "Java"
|
||||
return Get-ChildItem $javaDir | ForEach-Object {
|
||||
$javaBinPath = Join-Path $_ "bin"
|
||||
$rawVersion = & cmd /c "`"$javaBinPath\java.exe`" -version 2>&1" | Out-String
|
||||
$rawVersion -match 'openjdk version "(?<version>.+)"' | Out-Null
|
||||
$version = $Matches.Version
|
||||
if ($version -match $DefaultVersion) {
|
||||
$postfix = "(default)"
|
||||
} else {
|
||||
$postfix = ""
|
||||
}
|
||||
return "Java $version $postfix"
|
||||
} | Sort-Object {
|
||||
$version = ($_.Split(" ")[1]).Split("_")[0]
|
||||
return [System.Version]$version
|
||||
}
|
||||
}
|
||||
|
||||
function Get-RustVersion {
|
||||
$rustVersion = [regex]::matches($(rustc --version), "\d+\.\d+\.\d+").Value
|
||||
return $rustVersion
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
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
|
||||
@@ -17,7 +8,8 @@ function Get-JavaVersions {
|
||||
|
||||
return $javaVersions | Sort-Object $sortRules | ForEach-Object {
|
||||
$javaPath = $_.Value
|
||||
$version = Get-JavaFullVersion "$javaPath"
|
||||
# Take semver from the java path
|
||||
$version = (Split-Path $javaPath) -replace "\w:\\.*\\"
|
||||
$defaultPostfix = ($javaPath -eq $defaultJavaPath) ? " (default)" : ""
|
||||
|
||||
[PSCustomObject] @{
|
||||
|
||||
Reference in New Issue
Block a user