install-openjdk.bash 3.44 KB
Newer Older
1
2
3
#!/usr/bin/env bash
DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

4
. ${DIR}/install-jenv.bash
5
6

jdk=$1
Mark's avatar
Mark committed
7
8
9
if [[ -z $jdk ]]; then
    jdk=openjdk8
fi
10
11
12
13
14

# empty variables are not necessary, but a hint that these are not
# lexically scoped in their modification.
topdir=
dist=
15
function determine_openjdk() {
16
17
18
19
    case $(uname) in
        Darwin)
            case $jdk in
                openjdk8)
20
21
                    topdir=jdk8u302-b08
                    dist="https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/OpenJDK8U-jdk_x64_mac_hotspot_8u302b08.tar.gz"
22
23
                    ;;
                openjdk11)
24
25
                    topdir=jdk-11.0.12+7
                    dist="https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_x64_mac_hotspot_11.0.12_7.tar.gz"
26
                    ;;
27
                openjdk14)  # Need version from adoptium
28
29
                    topdir=jdk-14.0.2+12
                    dist="https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.2%2B12/OpenJDK14U-jdk_x64_mac_hotspot_14.0.2_12.tar.gz"
30
                    ;;
31
                openjdk15) # Need version from adoptium
32
33
34
                    topdir=jdk-15+36
                    dist="https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15%2B36/OpenJDK15U-jdk_x64_mac_hotspot_15_36.tar.gz"
                    ;;
35
36
37
                openjdk16)
                    topdir=jdk-16.0.2+7
                    dist="https://github.com/adoptium/temurin16-binaries/releases/download/jdk-16.0.2%2B7/OpenJDK16U-jdk_x64_mac_hotspot_16.0.2_7.tar.gz"
38
esac
39
40
41
42
            ;;
        Linux)
            case $jdk in
                openjdk8)
43
44
                    topdir=jdk8u302-b08
                    dist="https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tar.gz"
45
46
                    ;;
                openjdk11)
47
48
                    topdir=jdk-11.0.8+10
                    dist="https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.8%2B10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.8_10.tar.gz"
49
                    ;;
50
                openjdk14) # Need version from adoptium
51
52
                    topdir=jdk-14.0.2+12
                    dist="https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.2%2B12/OpenJDK14U-jdk_x64_linux_hotspot_14.0.2_12.tar.gz"
53
                    ;;
54
                openjdk15) # Need version from adoptium
55
56
57
                    topdir=jdk-15+36
                    dist="https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15%2B36/OpenJDK15U-jdk_x64_linux_hotspot_15_36.tar.gz"
                    ;;
58
59
60
                openjdk16)
                    topdir=jdk-16.0.2+7
                    dist="https://github.com/adoptium/temurin16-binaries/releases/download/jdk-16.0.2%2B7/OpenJDK16U-jdk_x64_linux_hotspot_16.0.2_7.tar.gz"
61
esac
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
            ;;
        *)
            echo No known dist for $(uname)
    esac
}

tmpdir=/var/tmp

function download_and_extract() {
    pushd ${tmpdir} && wget --continue ${dist}
    
    tar xvz -f $(basename ${dist})

    popd
}

function add_jdk() {
    echo $dist
    echo $tmpdir
    case $(uname) in
        Darwin)
            jenv add ${tmpdir}/${topdir}/Contents/Home
            ;;
        Linux)
            jenv add ${tmpdir}/${topdir}
            ;;
    esac
}

91
determine_openjdk
92
93
download_and_extract
add_jdk
94

Mark's avatar
Mark committed
95
. ${DIR}/set-jdk.bash
96

97
jenv doctor