From c3409c4aa7044672c83aaf3dd3bd825b6040bc7d Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 18 Oct 2019 19:45:50 +0200 Subject: [PATCH] [ci] Download openjdk from https://pmd-code.org/openjdk/ * Note: Download is only possible from travis * Make openjdk version configurable in .travis.yml * Skip download, if already downloaded --- .travis.yml | 2 +- .travis/before_install.sh | 4 +++- .travis/install-openjdk.sh | 27 ++++++++++++++++++--------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 03edd19b30..098ce59ba9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,7 @@ matrix: language: shell before_install: - - bash .travis/before_install.sh + - bash .travis/before_install.sh "11.0.4+11" - source ${HOME}/java.env install: true before_script: true diff --git a/.travis/before_install.sh b/.travis/before_install.sh index 103ea55685..aaacdbb144 100644 --- a/.travis/before_install.sh +++ b/.travis/before_install.sh @@ -6,9 +6,11 @@ source .travis/common-functions.sh travis_debug +OPENJDK_VERSION=$1 + bash .travis/setup-secrets.sh bash .travis/configure-maven.sh -bash .travis/install-openjdk.sh +bash .travis/install-openjdk.sh $OPENJDK_VERSION if travis_isLinux; then diff --git a/.travis/install-openjdk.sh b/.travis/install-openjdk.sh index 9baf5c2a9d..1e07be76e9 100644 --- a/.travis/install-openjdk.sh +++ b/.travis/install-openjdk.sh @@ -9,29 +9,38 @@ set -e source .travis/logger.sh source .travis/common-functions.sh -VERSION_TAG="11.0.4+11" +# 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 -log_info "Installing OpenJDK ${VERSION_TAG} for ${TRAVIS_OS_NAME}" +log_info "Installing OpenJDK${OPENJDK_MAJOR}U ${VERSION_TAG} for ${TRAVIS_OS_NAME}" if travis_isOSX; then - DOWNLOAD_URL=https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-${VERSION_TAG/+/%2B}/OpenJDK11U-jdk_x64_mac_hotspot_${VERSION_TAG/+/_}.tar.gz + DOWNLOAD_URL=${BASE_URL}/jdk-${VERSION_TAG/+/%2B}/OpenJDK${OPENJDK_MAJOR}U-jdk_x64_mac_hotspot_${VERSION_TAG/+/_}.tar.gz COMPONENTS_TO_STRIP=3 # e.g. jdk-11.0.3+7/Contents/Home/bin/java elif travis_isWindows; then - DOWNLOAD_URL=https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-${VERSION_TAG/+/%2B}/OpenJDK11U-jdk_x64_windows_hotspot_${VERSION_TAG/+/_}.zip + DOWNLOAD_URL=${BASE_URL}/jdk-${VERSION_TAG/+/%2B}/OpenJDK${OPENJDK_MAJOR}U-jdk_x64_windows_hotspot_${VERSION_TAG/+/_}.zip else - DOWNLOAD_URL=https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-${VERSION_TAG/+/%2B}/OpenJDK11U-jdk_x64_linux_hotspot_${VERSION_TAG/+/_}.tar.gz + DOWNLOAD_URL=${BASE_URL}/jdk-${VERSION_TAG/+/%2B}/OpenJDK${OPENJDK_MAJOR}U-jdk_x64_linux_hotspot_${VERSION_TAG/+/_}.tar.gz COMPONENTS_TO_STRIP=1 # e.g. openjdk-11.0.3+7/bin/java fi OPENJDK_ARCHIVE=$(basename $DOWNLOAD_URL) LOCAL_DIR=${HOME}/.cache/openjdk -TARGET_DIR=${HOME}/openjdk11 +TARGET_DIR=${HOME}/openjdk${OPENJDK_MAJOR} mkdir -p ${LOCAL_DIR} mkdir -p ${TARGET_DIR} -log_info "Downloading from ${DOWNLOAD_URL} to ${LOCAL_DIR}" -wget --directory-prefix ${LOCAL_DIR} --timestamping --continue ${DOWNLOAD_URL} +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 log_info "Extracting to ${TARGET_DIR}" if travis_isWindows; then @@ -44,10 +53,10 @@ fi cat > ${HOME}/java.env <