Skip to content

Commit 592aa12

Browse files
committed
chore: add java 8 compatibility check
1 parent 3f19fa1 commit 592aa12

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# Github action job to test core java library features on
15+
# downstream client libraries before they are released.
16+
on:
17+
pull_request:
18+
name: Java 8 compatibility check
19+
jobs:
20+
java8-compatibility-check:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-java@v4
25+
with:
26+
java-version: 11
27+
distribution: temurin
28+
cache: maven
29+
- name: Install Maven modules to local Maven repository
30+
run: |
31+
mvn install -B -ntp -T 1C -DskipTests -Dclirr.skip -Dcheckstyle.skip -Denforcer.skip
32+
- name: Check Java 8 compatibility for class files
33+
shell: bash
34+
run: |
35+
find . -type f -name "*.class" -path "*/classes/*" -not -path "*/grpc-*" -not -path "*/proto-*/*" -print |\
36+
while IFS= read -r class_file; do
37+
version=$(javap -v "${class_file}" | grep "major version" | cut -d ' ' -f 5)
38+
if [[ "${version}" != "52" ]]; then
39+
echo "${class_file} is not compatible with Java 8."
40+
exit 1
41+
fi
42+
done
43+
echo "All class files are compatible with Java 8."

0 commit comments

Comments
 (0)