• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
12# Switch to desired JDK, download if required:
13function install_jdk {
14  JDK_URL=$1
15
16  FILENAME="${JDK_URL##*/}"
17
18  rm -rf /tmp/jdk/$JDK
19  mkdir -p /tmp/jdk/$JDK
20
21  if [ ! -f "/tmp/jdk/$FILENAME" ]
22  then
23    curl -L $JDK_URL -o /tmp/jdk/$FILENAME
24  fi
25
26  tar -xzf /tmp/jdk/$FILENAME -C /tmp/jdk/$JDK --strip-components 1
27
28  if [ -z "${2+false}" ]
29  then
30    export JAVA_HOME="/tmp/jdk/$JDK"
31    export JDK_HOME="${JAVA_HOME}"
32    export JAVAC="${JAVA_HOME}/bin/javac"
33    export PATH="${JAVA_HOME}/bin:${PATH}"
34  fi
35}
36
37source $HOME/.jdk_switcher_rc
38case "$JDK" in
395)
40  jdk_switcher use oraclejdk8
41  install_jdk $JDK5_URL false
42  ;;
436)
44  jdk_switcher use openjdk6
45  ;;
467|8)
47  jdk_switcher use oraclejdk${JDK}
48  ;;
498-ea)
50  install_jdk $JDK8_EA_URL
51  ;;
529-ea)
53  install_jdk $JDK9_EA_URL
54  ;;
559-ea-stable)
56  install_jdk $JDK9_EA_STABLE_URL
57  ;;
58esac
59
60# Do not use "~/.mavenrc" set by Travis (https://github.com/travis-ci/travis-ci/issues/3893),
61# because it prevents execution of JaCoCo during integration tests for jacoco-maven-plugin,
62# and "-XMaxPermSize" not supported by JDK 9
63export MAVEN_SKIP_RC=true
64
65# Build:
66# TODO(Godin): see https://github.com/jacoco/jacoco/issues/300 about "bytecode.version"
67case "$JDK" in
685)
69  if [[ ${TRAVIS_PULL_REQUEST} == 'false' && ${TRAVIS_BRANCH} == 'master' ]]
70  then
71    # goal "deploy:deploy" used directly instead of "deploy" phase to avoid pollution of Maven repository by "install" phase
72    mvn -V -B -e -f org.jacoco.build verify sonar:sonar deploy:deploy -DdeployAtEnd -Djdk.version=1.5 --toolchains=./.travis/toolchains.xml --settings=./.travis/settings.xml -Dsonar.host.url=${SONARQUBE_URL} -Dsonar.login=${SONARQUBE_TOKEN}
73    python ./.travis/trigger-site-deployment.py
74  else
75    mvn -V -B -e verify -Djdk.version=1.5 --toolchains=./.travis/toolchains.xml
76  fi
77  ;;
786)
79  mvn -V -B -e verify -Dbytecode.version=1.6
80  ;;
817)
82  mvn -V -B -e verify -Dbytecode.version=1.7
83  ;;
848 | 8-ea)
85  mvn -V -B -e verify -Dbytecode.version=1.8 -Decj=${ECJ:-}
86  ;;
879-ea | 9-ea-stable)
88  # Groovy version should be updated to get rid of "--add-opens" options (see https://twitter.com/CedricChampeau/status/807285853580103684)
89  export MAVEN_OPTS="--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED"
90
91  # see https://bugs.openjdk.java.net/browse/JDK-8131041 about "java.locale.providers"
92  mvn -V -B -e verify -Dbytecode.version=1.9 \
93    -DargLine=-Djava.locale.providers=JRE,SPI
94  ;;
95*)
96  echo "Incorrect JDK [$JDK]"
97  exit 1;
98  ;;
99esac
100