From a0656ad9b456750dfb92253c17669b6d4d882b3f Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev <50947177+Darleev@users.noreply.github.com> Date: Mon, 18 Jan 2021 19:45:17 +0700 Subject: [PATCH] [Windows] Add JAVA section to docs. (#2467) * [macOS] Fail Pester tests on error * return it back * git pus * added fix for java docs * changed java place --- .../SoftwareReport.Generator.ps1 | 6 +++- .../SoftwareReport/SoftwareReport.Java.psm1 | 30 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 images/win/scripts/SoftwareReport/SoftwareReport.Java.psm1 diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index 9d69ee1b9..07ea2083f 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -6,6 +6,7 @@ Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Common.psm1") -DisableNam Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Databases.psm1") -DisableNameChecking Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Helpers.psm1") -DisableNameChecking Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Tools.psm1") -DisableNameChecking +Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Java.psm1") -DisableNameChecking Import-Module (Join-Path $PSScriptRoot "SoftwareReport.VisualStudio.psm1") -DisableNameChecking $markdown = "" @@ -32,7 +33,6 @@ $markdown += New-MDHeader "Language and Runtime" -Level 3 $markdown += New-MDList -Style Unordered -Lines (@( (Get-BashVersion), (Get-GoVersion), - (Get-JavaVersionsList -DefaultVersion "1.8.0") (Get-JuliaVersion), (Get-NodeVersion), (Get-PerlVersion), @@ -148,6 +148,10 @@ $markdown += New-MDList -Style Unordered -Lines @( (Get-SeleniumWebDriverVersion -Driver "iexplorer") ) +$markdown += New-MDHeader "Java" -Level 3 +$markdown += Get-JavaVersions | New-MDTable +$markdown += New-MDNewLine + $markdown += New-MDHeader "Shells" -Level 3 $markdown += Get-ShellTarget $markdown += New-MDNewLine diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Java.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.Java.psm1 new file mode 100644 index 000000000..bfab1e24d --- /dev/null +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Java.psm1 @@ -0,0 +1,30 @@ +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 + $sortRules = @{ + Expression = { [Int32]$_.Name.Split("_")[2] } + Descending = $false + } + + return $javaVersions | Sort-Object $sortRules | ForEach-Object { + $javaPath = $_.Value + $version = Get-JavaFullVersion "$javaPath" + $vendor = $version.StartsWith("1.7") ? "Zulu" : "AdoptOpenJDK" + $defaultPostfix = ($javaPath -eq $defaultJavaPath) ? " (default)" : "" + + [PSCustomObject] @{ + "Version" = $version + $defaultPostfix + "Vendor" = $vendor + "Environment Variable" = $_.Name + } + } +} \ No newline at end of file