diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 83ef7f9c2cf..6529efcd965 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,7 +25,7 @@ jobs: strategy: fail-fast: false matrix: - java: [8, 11, 17] + java: [11, 17] steps: - uses: actions/checkout@v3 - uses: actions/setup-java@v3 @@ -36,6 +36,24 @@ jobs: - run: .kokoro/build.sh env: JOB_TYPE: test + units-java8: + name: "units (8)" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + java-version: 8 + distribution: zulu + - run: echo "JAVA8_HOME=${JAVA_HOME}" >> $GITHUB_ENV + - uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: zulu + - run: echo "JAVA11_HOME=${JAVA_HOME}" >> $GITHUB_ENV + - run: .kokoro/build.sh + env: + JOB_TYPE: test windows: runs-on: windows-latest steps: diff --git a/.kokoro/build.sh b/.kokoro/build.sh index 56aa8c8f5c2..7674e8ec989 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -23,6 +23,17 @@ cd ${scriptDir}/.. # include common functions source ${scriptDir}/common.sh +function setJava() { + export JAVA_HOME=$1 + export PATH=${JAVA_HOME}/bin:$PATH +} + +# units-java8 uses both JDK 11 and JDK 8. GraalVM dependencies require JDK 11 to +# compile the classes touching GraalVM classes. +if [ ! -z "${JAVA11_HOME}" ]; then + setJava "${JAVA11_HOME}" +fi + # Print out Maven & Java version mvn -version echo ${JOB_TYPE} @@ -42,6 +53,13 @@ if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTI export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_GFILE_DIR}/${GOOGLE_APPLICATION_CREDENTIALS}) fi +# units-java8 uses both JDK 11 and JDK 8. We ensure the generated class files +# are compatible with Java 8 when running tests. +if [ ! -z "${JAVA8_HOME}" ]; then + setJava "${JAVA8_HOME}" + mvn -version +fi + RETURN_CODE=0 set +e diff --git a/pom.xml b/pom.xml index 6f81a5acc31..a39c58de864 100644 --- a/pom.xml +++ b/pom.xml @@ -224,4 +224,17 @@ + + + + compiler-release-8 + + [9,] + + + 8 + + +