2019-07-26 16:05:54 +03:00
|
|
|
Param(
|
|
|
|
[string] $InstallDestination = $null
|
|
|
|
)
|
|
|
|
|
2019-05-24 08:14:37 +03:00
|
|
|
$ErrorActionPreference = 'Stop'
|
2019-05-01 03:19:56 +03:00
|
|
|
|
|
|
|
if ($IsMacOS) {
|
|
|
|
$url = "https://download.oracle.com/java/GA/jdk10/10.0.2/19aef61b38124481863b1413dce1855f/13/openjdk-10.0.2_osx-x64_bin.tar.gz"
|
|
|
|
} elseif ($IsLinux) {
|
|
|
|
$url = "https://download.oracle.com/java/GA/jdk10/10.0.2/19aef61b38124481863b1413dce1855f/13/openjdk-10.0.2_linux-x64_bin.tar.gz"
|
|
|
|
} else {
|
|
|
|
$url = "https://download.java.net/java/GA/jdk10/10.0.2/19aef61b38124481863b1413dce1855f/13/openjdk-10.0.2_windows-x64_bin.tar.gz"
|
|
|
|
}
|
|
|
|
|
|
|
|
$jdk = Join-Path "$HOME" "openjdk"
|
2019-07-26 16:05:54 +03:00
|
|
|
if ($InstallDestination) {
|
|
|
|
$jdk = $InstallDestination
|
|
|
|
}
|
|
|
|
Write-Host "Install destination is '$ts'..."
|
|
|
|
|
2019-05-01 03:19:56 +03:00
|
|
|
$jdkTemp = Join-Path "$HOME" "openjdk-temp"
|
|
|
|
$archive = Join-Path "$jdkTemp" "openjdk.tar.gz"
|
|
|
|
|
|
|
|
# download
|
|
|
|
Write-Host "Downloading OpenJDK to '$archive'..."
|
|
|
|
New-Item -ItemType Directory -Force -Path "$jdkTemp" | Out-Null
|
|
|
|
(New-Object System.Net.WebClient).DownloadFile("$url", "$archive")
|
|
|
|
|
|
|
|
# install
|
|
|
|
Write-Host "Extracting OpenJDK to '$jdk'..."
|
|
|
|
New-Item -ItemType Directory -Force -Path "$jdk" | Out-Null
|
|
|
|
if ($IsMacOS -or $IsLinux) {
|
|
|
|
tar -vxzf "$archive" -C "$jdk"
|
|
|
|
} else {
|
|
|
|
tar --force-local -vxzf "$archive" -C "$jdk"
|
|
|
|
}
|
|
|
|
|
|
|
|
# set the JAVA_HOME
|
|
|
|
if ($IsMacOS) {
|
|
|
|
$java_home = Join-Path "$jdk" "jdk-10.0.2.jdk/Contents/Home"
|
|
|
|
} else {
|
|
|
|
$java_home = Join-Path "$jdk" "jdk-10.0.2"
|
|
|
|
}
|
|
|
|
Write-Host "##vso[task.setvariable variable=JAVA_HOME;]$java_home"
|
|
|
|
|
2019-06-25 10:10:09 +03:00
|
|
|
# make sure that JAVA_HOME/bin is in the PATH
|
|
|
|
$javaBin = Join-Path "$java_home" "bin"
|
|
|
|
Write-Host "##vso[task.setvariable variable=PATH;]$javaBin;$env:PATH";
|
|
|
|
|
2019-05-01 03:19:56 +03:00
|
|
|
exit $LASTEXITCODE
|