source: tags/1.9.2/ci/set-jdk.bash

Last change on this file was 15697, checked in by Mark Evenson, 18 months ago

ci: update openjdk versions

Deprecate openjdk19 in favor of openjdk20 as it is the current
development release.

Have <file:ci/set-jdk.bash> only use its arguments to set jdk
version, while attempting to be more verbose and guard against failure
to interpolate these values as we go.

Usage:

set-jdk OPENJDK_VERSION ABCL_ROOT

where

OPENJDK_VERSION is of the form 'openjdk8', 'openjdk19', etc.

ABCL_ROOT is the root of the ABCL source tree

File size: 1.7 KB
Line 
1function set_jdk() {
2    abcl_jdk=$1
3    if [[ -z ${abcl_jdk} ]]; then
4        abcl_jdk=openjdk8
5    fi
6
7    echo Configuring JDK from ${abcl_jdk}
8
9    dir=$2
10    if [[ -z ${dir} ]]; then
11        dir=${ABCL_ROOT}
12    fi
13
14    if [[ -z ${ABCL_ROOT} ]]; then
15        dir=/var/tmp/set-jdk.$$/
16    fi
17
18    . ${DIR}/ensure-jenv-is-present.bash
19
20    echo Available jenv versions $(jenv versions)
21
22    case ${abcl_jdk} in
23        openjdk8)
24            version=$(jenv versions | grep ^\ *1\.8\.[0-9] | tail -1 | sed s/*//)
25            ;;
26        openjdk11)
27            version=$(jenv versions | grep ^\ *11\.[0-9] | tail -1 | sed s/*//)
28            ;;
29        openjdk17)
30            version=$(jenv versions | grep ^\ *17\.[0-9] | tail -1 | sed s/*//)
31            ;;
32        openjdk17)
33            version=$(jenv versions | grep ^\ *19\.[0-9] | tail -1 | sed s/*//)
34            ;;
35        openjdk20)
36            version=$(jenv versions | grep ^\ *20\.[0-9] | tail -1 | sed s/*//)
37            ;;
38        *)
39            echo Failed to find an available JDK matching ${abcl_jdk}
40            echo   in $(jenv versions)
41            echo
42            echo Falling back to grabbing the last one listed
43            version=$(jenv versions | tail -1 | sed s/*//)
44    esac
45
46    if [[ ! -d ${dir} ]]; then
47        echo Creating directory ${dir}
48        mkdir ${dir}
49    fi
50
51    pushd ${dir}
52
53    if [[ 0 -ne $(jenv local ${version}) ]]; then 
54       echo Failed to set local JDK to ${version}
55    fi 
56    # but practically we guard every invocation of jenv this way
57    if [[ 0 -ne $(jenv global ${version}) ]]; then 
58       echo Failed to set global JDK to ${version}
59    fi 
60
61    echo Local version to set $(jenv version)
62
63    popd
64}
65
66set_jdk ${ABCL_JDK} ${ABCL_ROOT}
Note: See TracBrowser for help on using the repository browser.