[MacOS] Move preinstalled java distributions to the toolcache directory (#2883)

* Move java to the toolcache

* resolved comments

* added sudo for ln command

* fixed versions and added symlink

* fixed openjdk.sh

* fixed typo

* updated SoftwareReport

* fixed SoftwareReport

* fixed SoftwareReport

* fixed tool name

Co-authored-by: Nikita Bykov <v-nibyko@microsoft.com>
This commit is contained in:
Nikita Bykov
2021-03-16 17:13:54 +03:00
committed by GitHub
parent 758e6ef267
commit ef6e8c905f
3 changed files with 40 additions and 31 deletions

View File

@@ -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 = Get-Item env:JAVA_HOME
$javaVersions = Get-Item env:JAVA_HOME_*_X64
@@ -17,12 +8,13 @@ function Get-JavaVersions {
return $javaVersions | Sort-Object $sortRules | ForEach-Object {
$javaPath = $_.Value
$version = Get-JavaFullVersion $javaPath
# Take semver from the java path
$version = $javaPath.split('/')[5]
$defaultPostfix = ($javaPath -eq $defaultJavaPath) ? " (default)" : ""
[PSCustomObject] @{
"Version" = $version + $defaultPostfix
"Vendor" = "AdoptOpenJDK"
"Vendor" = "Adopt OpenJDK"
"Environment Variable" = $_.Name
}
}