diff --git a/images/win/scripts/Installers/Install-JavaTools.ps1 b/images/win/scripts/Installers/Install-JavaTools.ps1 index 96282371b..8ab75910c 100644 --- a/images/win/scripts/Installers/Install-JavaTools.ps1 +++ b/images/win/scripts/Installers/Install-JavaTools.ps1 @@ -3,33 +3,22 @@ ## Desc: Install various JDKs and java tools ################################################################################ +Import-Module -Name ImageHelpers -Force + # Download the Azul Systems Zulu JDKs # See https://www.azul.com/downloads/azure-only/zulu/ -$azulJDK7Uri = 'https://repos.azul.com/azure-only/zulu/packages/zulu-7/7u232/zulu-7-azure-jdk_7.31.0.5-7.0.232-win_x64.zip' -$azulJDK8Uri = 'https://repos.azul.com/azure-only/zulu/packages/zulu-8/8u222/zulu-8-azure-jdk_8.40.0.25-8.0.222-win_x64.zip' -$azulJDK11Uri = 'https://repos.azul.com/azure-only/zulu/packages/zulu-11/11.0.4/zulu-11-azure-jdk_11.33.15-11.0.4-win_x64.zip' -$azulJDK13Uri = 'https://repos.azul.com/azure-only/zulu/packages/zulu-13/13.0.3/zulu-13-azure-jdk_13.31.11-13.0.3-win_x64.zip' +$azulJDKURLs = @( + 'https://repos.azul.com/azure-only/zulu/packages/zulu-7/7u232/zulu-7-azure-jdk_7.31.0.5-7.0.232-win_x64.zip', + 'https://repos.azul.com/azure-only/zulu/packages/zulu-8/8u222/zulu-8-azure-jdk_8.40.0.25-8.0.222-win_x64.zip', + 'https://repos.azul.com/azure-only/zulu/packages/zulu-11/11.0.4/zulu-11-azure-jdk_11.33.15-11.0.4-win_x64.zip', + 'https://repos.azul.com/azure-only/zulu/packages/zulu-13/13.0.3/zulu-13-azure-jdk_13.31.11-13.0.3-win_x64.zip' +) -cd $env:TEMP - -Invoke-WebRequest -UseBasicParsing -Uri $azulJDK7Uri -OutFile azulJDK7.zip -Invoke-WebRequest -UseBasicParsing -Uri $azulJDK8Uri -OutFile azulJDK8.zip -Invoke-WebRequest -UseBasicParsing -Uri $azulJDK11Uri -OutFile azulJDK11.zip -Invoke-WebRequest -UseBasicParsing -Uri $azulJDK13Uri -OutFile azulJDK13.zip - -# Expand the zips -Expand-Archive -Path azulJDK7.zip -DestinationPath "C:\Program Files\Java\" -Force -Expand-Archive -Path azulJDK8.zip -DestinationPath "C:\Program Files\Java\" -Force -Expand-Archive -Path azulJDK11.zip -DestinationPath "C:\Program Files\Java\" -Force -Expand-Archive -Path azulJDK13.zip -DestinationPath "C:\Program Files\Java\" -Force - -# Deleting zip folders -Remove-Item -Recurse -Force azulJDK7.zip -Remove-Item -Recurse -Force azulJDK8.zip -Remove-Item -Recurse -Force azulJDK11.zip -Remove-Item -Recurse -Force azulJDK13.zip - -Import-Module -Name ImageHelpers -Force +foreach ($azulJDKURL in $azulJDKURLs) +{ + $archivePath = Start-DownloadWithRetry -Url $azulJDKURL -Name $([IO.Path]::GetFileName($azulJDKURL)) + Expand-Archive -Path $archivePath -DestinationPath "C:\Program Files\Java\" +} $currentPath = Get-MachinePath @@ -38,7 +27,7 @@ $newPathSegments = @() foreach ($pathSegment in $pathSegments) { - if($pathSegment -notlike '*java*') + if ($pathSegment -notlike '*java*') { $newPathSegments += $pathSegment } @@ -93,14 +82,7 @@ setx MAVEN_OPTS $maven_opts /M $uri = 'https://ayera.dl.sourceforge.net/project/cobertura/cobertura/2.1.1/cobertura-2.1.1-bin.zip' $coberturaPath = "C:\cobertura-2.1.1" -cd $env:TEMP - -Invoke-WebRequest -UseBasicParsing -Uri $uri -OutFile cobertura.zip - -# Expand the zip -Expand-Archive -Path cobertura.zip -DestinationPath "C:\" -Force - -# Deleting zip folder -Remove-Item -Recurse -Force cobertura.zip +$archivePath = Start-DownloadWithRetry -Url $uri -Name "cobertura.zip" +Expand-Archive -Path $archivePath -DestinationPath "C:\" setx COBERTURA_HOME $coberturaPath /M