[Windows] Replace '+' to '-' in java path (#3028)

* Replace + to - in Java path

* Fix comment

* fix vendor name in software report
This commit is contained in:
Mikhail Timofeev
2021-03-27 10:50:50 +03:00
committed by GitHub
parent dd506183e2
commit b56d115a16
2 changed files with 6 additions and 3 deletions

View File

@@ -9,12 +9,14 @@ function Get-JavaVersions {
return $javaVersions | Sort-Object $sortRules | ForEach-Object {
$javaPath = $_.Value
# Take semver from the java path
$version = (Split-Path $javaPath) -replace "\w:\\.*\\"
# The path contains '-' sign in the version number instead of '+' due to the following issue, need to substitute it back https://github.com/actions/virtual-environments/issues/3014
$versionInPath = (Split-Path $javaPath) -replace "\w:\\.*\\"
$version = $versionInPath -replace '-', '+'
$defaultPostfix = ($javaPath -eq $defaultJavaPath) ? " (default)" : ""
[PSCustomObject] @{
"Version" = $version + $defaultPostfix
"Vendor" = "AdoptOpenJDK"
"Vendor" = "Adopt OpenJDK"
"Environment Variable" = $_.Name
}
}