From 77e299148d40feb565b612a359f19f965619b0b6 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com> Date: Mon, 25 Oct 2021 16:30:47 +0300 Subject: [PATCH] [Windows] Do not use M2_HOME env var to get mvn path (#4333) * Do not use M2_HOME env var to get mvn path * use Get-MachinePath to get mvn path --- images/win/scripts/Installers/Install-JavaTools.ps1 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/images/win/scripts/Installers/Install-JavaTools.ps1 b/images/win/scripts/Installers/Install-JavaTools.ps1 index f4a0b9703..4a798a7c7 100644 --- a/images/win/scripts/Installers/Install-JavaTools.ps1 +++ b/images/win/scripts/Installers/Install-JavaTools.ps1 @@ -134,15 +134,12 @@ Choco-Install -PackageName ant -ArgumentList "-i" Choco-Install -PackageName maven -ArgumentList "-i" Choco-Install -PackageName gradle -# Move maven variables to Machine. They may not be in the environment for this script so we need to read them from the registry. -$userEnvironmentKey = 'Registry::HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' - -$m2_home = (Get-ItemProperty -Path $userEnvironmentKey -Name M2_HOME).M2_HOME -$m2 = $m2_home + '\bin' +# Add maven env variables to Machine +[string]$m2 = (Get-MachinePath).Split(";") -match "maven" $maven_opts = '-Xms256m' $m2_repo = 'C:\ProgramData\m2' -New-Item -Path $m2_repo -ItemType Directory -Force +New-Item -Path $m2_repo -ItemType Directory -Force | Out-Null setx M2 $m2 /M setx M2_REPO $m2_repo /M