mirror of
https://github.com/actions/runner-images.git
synced 2025-12-12 20:26:49 +00:00
[Ubuntu] Add Eclipse Temurin (Adoptium) to Java installer (#4868)
This commit is contained in:
@@ -1,19 +1,22 @@
|
||||
function Get-JavaVersions {
|
||||
$toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "Java_Adopt_jdk"
|
||||
$javaToolcacheVersions = Get-ChildItem $toolcachePath -Name | Sort-Object { [int]$_.Split(".")[0] }
|
||||
$javaToolcacheVersions = Get-ChildItem $env:AGENT_TOOLSDIRECTORY/Java*/* -Directory | Sort-Object { [int]$_.Name.Split(".")[0] }
|
||||
|
||||
return $javaToolcacheVersions | ForEach-Object {
|
||||
$majorVersion = $_.split(".")[0]
|
||||
$fullVersion = $_.Replace("-", "+")
|
||||
$existingVersions = $javaToolcacheVersions | ForEach-Object {
|
||||
$majorVersion = $_.Name.split(".")[0]
|
||||
$fullVersion = $_.Name.Replace("-", "+")
|
||||
$defaultJavaPath = $env:JAVA_HOME
|
||||
$javaPath = Get-Item env:JAVA_HOME_${majorVersion}_X64
|
||||
|
||||
$defaultPostfix = ($javaPath.Value -eq $defaultJavaPath) ? " (default)" : ""
|
||||
$vendorName = ($_.FullName -like '*Java_Adopt_jdk*') ? "Adopt OpenJDK" : "Eclipse Temurin"
|
||||
|
||||
[PSCustomObject] @{
|
||||
"Version" = $fullVersion + $defaultPostfix
|
||||
"Vendor" = "Adopt OpenJDK"
|
||||
"Vendor" = $vendorName
|
||||
"Environment Variable" = $javaPath.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
# Return all the vendors which are not Adopt, also look for version 12 of Adopt (Eclipse Temurin does not have this version)
|
||||
$versionsToReturn = $existingVersions | Where-Object {$_.Vendor -notlike "Adopt*" -or $_.Version.Split(".")[0] -eq 12}
|
||||
return $versionsToReturn
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user