2019-10-18 16:40:44 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2019-04-27 16:54:28 +02:00
|
|
|
#
|
2019-07-20 10:30:30 +02:00
|
|
|
# AdoptOpenJDK Builds from:
|
|
|
|
# https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/tag/jdk-11.0.4%2B11
|
2019-04-27 16:54:28 +02:00
|
|
|
#
|
|
|
|
|
2019-10-18 16:40:44 +02:00
|
|
|
source .travis/logger.sh
|
|
|
|
source .travis/common-functions.sh
|
|
|
|
|
2019-10-18 19:45:50 +02:00
|
|
|
# VERSION_TAG e.g. "11.0.4+11" or "13+33"
|
|
|
|
VERSION_TAG=$1
|
|
|
|
OPENJDK_MAJOR=${VERSION_TAG/.*/}
|
|
|
|
OPENJDK_MAJOR=${OPENJDK_MAJOR/+*/}
|
|
|
|
#BASE_URL=https://github.com/AdoptOpenJDK/openjdk${OPENJDK_MAJOR}-binaries/releases/download
|
|
|
|
BASE_URL=https://pmd-code.org/openjdk
|
2019-10-18 16:40:44 +02:00
|
|
|
|
2019-10-18 19:45:50 +02:00
|
|
|
log_info "Installing OpenJDK${OPENJDK_MAJOR}U ${VERSION_TAG} for ${TRAVIS_OS_NAME}"
|
2019-10-18 16:40:44 +02:00
|
|
|
|
|
|
|
if travis_isOSX; then
|
2019-10-18 19:45:50 +02:00
|
|
|
DOWNLOAD_URL=${BASE_URL}/jdk-${VERSION_TAG/+/%2B}/OpenJDK${OPENJDK_MAJOR}U-jdk_x64_mac_hotspot_${VERSION_TAG/+/_}.tar.gz
|
2019-04-27 17:39:50 +02:00
|
|
|
COMPONENTS_TO_STRIP=3 # e.g. jdk-11.0.3+7/Contents/Home/bin/java
|
2019-10-18 16:40:44 +02:00
|
|
|
elif travis_isWindows; then
|
2019-10-18 19:45:50 +02:00
|
|
|
DOWNLOAD_URL=${BASE_URL}/jdk-${VERSION_TAG/+/%2B}/OpenJDK${OPENJDK_MAJOR}U-jdk_x64_windows_hotspot_${VERSION_TAG/+/_}.zip
|
2019-04-27 16:54:28 +02:00
|
|
|
else
|
2019-10-18 19:45:50 +02:00
|
|
|
DOWNLOAD_URL=${BASE_URL}/jdk-${VERSION_TAG/+/%2B}/OpenJDK${OPENJDK_MAJOR}U-jdk_x64_linux_hotspot_${VERSION_TAG/+/_}.tar.gz
|
2019-04-27 17:39:50 +02:00
|
|
|
COMPONENTS_TO_STRIP=1 # e.g. openjdk-11.0.3+7/bin/java
|
2019-04-27 16:54:28 +02:00
|
|
|
fi
|
|
|
|
|
2019-07-20 10:30:30 +02:00
|
|
|
OPENJDK_ARCHIVE=$(basename $DOWNLOAD_URL)
|
|
|
|
|
2019-04-27 16:22:21 +02:00
|
|
|
LOCAL_DIR=${HOME}/.cache/openjdk
|
2019-10-18 19:45:50 +02:00
|
|
|
TARGET_DIR=${HOME}/openjdk${OPENJDK_MAJOR}
|
2019-04-27 16:22:21 +02:00
|
|
|
|
|
|
|
mkdir -p ${LOCAL_DIR}
|
|
|
|
mkdir -p ${TARGET_DIR}
|
2019-10-18 19:45:50 +02:00
|
|
|
if [ ! -e ${LOCAL_DIR}/${OPENJDK_ARCHIVE} ]; then
|
|
|
|
log_info "Downloading from ${DOWNLOAD_URL} to ${LOCAL_DIR}"
|
|
|
|
wget --directory-prefix ${LOCAL_DIR} --timestamping --continue ${DOWNLOAD_URL}
|
|
|
|
else
|
|
|
|
log_info "Skipped download, file ${LOCAL_DIR}/${OPENJDK_ARCHIVE} already exists"
|
|
|
|
fi
|
2019-10-18 16:40:44 +02:00
|
|
|
|
|
|
|
log_info "Extracting to ${TARGET_DIR}"
|
|
|
|
if travis_isWindows; then
|
|
|
|
7z x ${LOCAL_DIR}/${OPENJDK_ARCHIVE} -o${TARGET_DIR}
|
|
|
|
mv ${TARGET_DIR}/*/* ${TARGET_DIR}/
|
|
|
|
else
|
|
|
|
tar --extract --file ${LOCAL_DIR}/${OPENJDK_ARCHIVE} -C ${TARGET_DIR} --strip-components=${COMPONENTS_TO_STRIP}
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat > ${HOME}/java.env <<EOF
|
|
|
|
export JAVA_HOME="${TARGET_DIR}"
|
|
|
|
export PATH="${TARGET_DIR}/bin:${PATH}"
|
2019-10-18 19:45:50 +02:00
|
|
|
java -version
|
2019-10-18 16:40:44 +02:00
|
|
|
EOF
|
2019-04-27 16:22:21 +02:00
|
|
|
|
2019-10-18 16:40:44 +02:00
|
|
|
log_info "OpenJDK can be used via ${HOME}/java.env"
|
|
|
|
cat ${HOME}/java.env
|
|
|
|
source ${HOME}/java.env
|
2019-04-27 16:22:21 +02:00
|
|
|
|