mirror of
https://github.com/actions/runner-images.git
synced 2025-12-15 22:26:56 +00:00
Switch Java installation to AdoptOpenJDK on Windows (#1067)
* Switch Java installation to AdoptOpenJDK * Minor fix * Setup env vars * Reworked * Add variable for java root path * Validation improvement * Minor fix * Minor fix
This commit is contained in:
committed by
GitHub
parent
6f246a3b4f
commit
98df997b11
@@ -17,9 +17,20 @@ Function Validate-JavaVersion {
|
||||
# Take 7 & 8 for versions 1.7 and 1.8
|
||||
$versionNumber = $version.Split(".") | Select-Object -Last 1
|
||||
|
||||
$javaBin = [System.Environment]::GetEnvironmentVariable("JAVA_HOME_${versionNumber}_X64") + "\bin;"
|
||||
$javaPath = [System.Environment]::GetEnvironmentVariable("JAVA_HOME_${versionNumber}_X64")
|
||||
if ([string]::IsNullOrEmpty($javaPath))
|
||||
{
|
||||
Write-Host "Environment variable 'JAVA_HOME_${versionNumber}_X64' is null"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$javaBin = "$javaPath\bin;"
|
||||
$env:Path = $javaBin + $env:Path
|
||||
}
|
||||
else
|
||||
{
|
||||
Validate-JavaVersion -Version $Version
|
||||
}
|
||||
|
||||
$isJavaExists = $($(& $env:comspec "/s /c java -version 2>&1") | Out-String) -match '^(?<vendor>.+) version "(?<version>.+)".*'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user