Skip to content

Commit ba89167

Browse files
committed
ci: using JDK 11 to compile and JDK 8 to run junit (8)
1 parent f74c77d commit ba89167

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
java: [8, 11, 17]
28+
java: [11, 17]
2929
steps:
3030
- uses: actions/checkout@v3
3131
- uses: actions/setup-java@v3
@@ -36,6 +36,24 @@ jobs:
3636
- run: .kokoro/build.sh
3737
env:
3838
JOB_TYPE: test
39+
units-java8:
40+
name: "units (8)"
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v3
44+
- uses: actions/setup-java@v3
45+
with:
46+
java-version: 8
47+
distribution: zulu
48+
- run: echo "JAVA8_HOME=${JAVA_HOME}" >> $GITHUB_ENV
49+
- uses: actions/setup-java@v3
50+
with:
51+
java-version: 11
52+
distribution: zulu
53+
- run: echo "JAVA11_HOME=${JAVA_HOME}" >> $GITHUB_ENV
54+
- run: .kokoro/build.sh
55+
env:
56+
JOB_TYPE: test
3957
windows:
4058
runs-on: windows-latest
4159
steps:

.kokoro/build.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ cd ${scriptDir}/..
2323
# include common functions
2424
source ${scriptDir}/common.sh
2525

26+
function setJava() {
27+
export JAVA_HOME=$1
28+
export PATH=${JAVA_HOME}/bin:$PATH
29+
}
30+
31+
# units-java8 uses both JDK 11 and JDK 8. GraalVM dependencies require JDK 11 to
32+
# compile the classes touching GraalVM classes.
33+
if [ ! -z "${JAVA11_HOME}" ]; then
34+
setJava "${JAVA11_HOME}"
35+
fi
36+
2637
# Print out Maven & Java version
2738
mvn -version
2839
echo ${JOB_TYPE}
@@ -42,6 +53,13 @@ if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTI
4253
export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_GFILE_DIR}/${GOOGLE_APPLICATION_CREDENTIALS})
4354
fi
4455

56+
# units-java8 uses both JDK 11 and JDK 8. We ensure the generated class files
57+
# are compatible with Java 8 when running tests.
58+
if [ ! -z "${JAVA8_HOME}" ]; then
59+
setJava "${JAVA8_HOME}"
60+
mvn -version
61+
fi
62+
4563
RETURN_CODE=0
4664
set +e
4765

pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,17 @@
224224
</plugins>
225225
</reporting>
226226

227+
<profiles>
228+
<profile>
229+
<!-- JDK 9+ has the "release" option to ensure the generated bytecode is
230+
compatible with Java 8. -->
231+
<id>compiler-release-8</id>
232+
<activation>
233+
<jdk>[9,]</jdk>
234+
</activation>
235+
<properties>
236+
<maven.compiler.release>8</maven.compiler.release>
237+
</properties>
238+
</profile>
239+
</profiles>
227240
</project>

0 commit comments

Comments
 (0)