1#!/bin/bash 2 3set -euo pipefail 4 5# Prevent accidental execution outside of Travis: 6if [ -z "${TRAVIS+false}" ] 7then 8 echo "TRAVIS environment variable is not set" 9 exit 1 10fi 11 12function jdk_switcher { 13 DIR=$1 14 if [ ! -d "$DIR" ]; then 15 echo "Not found: $DIR" 16 exit 1 17 fi 18 export JAVA_HOME="$DIR" 19 export JDK_HOME="${JAVA_HOME}" 20 export JAVAC="${JAVA_HOME}/bin/javac" 21 export PATH="${JAVA_HOME}/bin:${PATH}" 22} 23 24# Switch to desired JDK, download if required: 25function install_jdk { 26 JDK_URL=$1 27 28 FILENAME="${JDK_URL##*/}" 29 30 rm -rf /tmp/jdk/$JDK 31 mkdir -p /tmp/jdk/$JDK 32 33 if [ ! -f "/tmp/jdk/$FILENAME" ] 34 then 35 curl -L $JDK_URL -o /tmp/jdk/$FILENAME 36 fi 37 38 tar -xzf /tmp/jdk/$FILENAME -C /tmp/jdk/$JDK --strip-components 1 39 40 if [ -z "${2+false}" ] 41 then 42 jdk_switcher "/tmp/jdk/$JDK" 43 fi 44} 45 46case "$JDK" in 475) 48 install_jdk $JDK5_URL false 49 ;; 506) 51 ;; 527) 53 jdk_switcher /usr/lib/jvm/java-7-openjdk-amd64 54 ;; 558) 56 jdk_switcher /usr/lib/jvm/java-8-oracle 57 ;; 588-ea) 59 install_jdk $JDK8_EA_URL 60 ;; 619) 62 install_jdk $JDK9_URL 63 ;; 6410-ea) 65 install_jdk $JDK10_EA_URL 66 ;; 67esac 68 69# Do not use "~/.mavenrc" set by Travis (https://github.com/travis-ci/travis-ci/issues/3893), 70# because it prevents execution of JaCoCo during integration tests for jacoco-maven-plugin, 71# and "-XMaxPermSize" not supported by JDK 9 72export MAVEN_SKIP_RC=true 73 74# Build: 75# TODO(Godin): see https://github.com/jacoco/jacoco/issues/300 about "bytecode.version" 76case "$JDK" in 775) 78 if [[ ${TRAVIS_PULL_REQUEST} == 'false' && ${TRAVIS_BRANCH} == 'master' ]] 79 then 80 # goal "deploy:deploy" used directly instead of "deploy" phase to avoid pollution of Maven repository by "install" phase 81 mvn -V -B -e -f org.jacoco.build verify deploy:deploy -DdeployAtEnd -Djdk.version=1.5 --toolchains=./.travis/toolchains.xml --settings=./.travis/settings.xml -Dsonar.host.url=${SONARQUBE_URL} -Dsonar.login=${SONARQUBE_TOKEN} 82 python ./.travis/trigger-site-deployment.py 83 else 84 mvn -V -B -e verify -Djdk.version=1.5 --toolchains=./.travis/toolchains.xml 85 fi 86 ;; 876) 88 mvn -V -B -e verify -Djdk.version=1.6 -Dbytecode.version=1.6 --toolchains=./.travis/travis-toolchains.xml 89 ;; 907) 91 mvn -V -B -e verify -Dbytecode.version=1.7 92 ;; 938 | 8-ea) 94 mvn -V -B -e verify -Dbytecode.version=1.8 -Decj=${ECJ:-} 95 ;; 969) 97 export MAVEN_OPTS="-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts" 98 mvn -V -B -e verify -Dbytecode.version=1.9 \ 99 -Dinvoker.mavenOpts="-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts" 100 ;; 10110-ea) 102 mvn -V -B -e verify -Dbytecode.version=1.9 103 ;; 104*) 105 echo "Incorrect JDK [$JDK]" 106 exit 1; 107 ;; 108esac 109