* Note: Download is only possible from travis
* Make openjdk version configurable in .travis.yml
* Skip download, if already downloaded
This commit is contained in:
Andreas Dangel
2019-10-18 19:45:50 +02:00
parent 23109d7b69
commit c3409c4aa7
3 changed files with 22 additions and 11 deletions

View File

@ -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

View File

@ -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

View File

@ -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 <<EOF
export JAVA_HOME="${TARGET_DIR}"
export PATH="${TARGET_DIR}/bin:${PATH}"
java -version
EOF
log_info "OpenJDK can be used via ${HOME}/java.env"
cat ${HOME}/java.env
source ${HOME}/java.env
java -version