Skip to content

Commit 5192426

Browse files
authored
chore: add java 8 compatibility check (#3688)
b/368579018
1 parent 25d3101 commit 5192426

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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/*" \
36+
-not -path "*/grpc-*/*" \
37+
-not -path "*/proto-*/*" \
38+
-not -path "*/gapic-generator-java/*" -print |\
39+
while IFS= read -r class_file; do
40+
version=$(javap -v "${class_file}" | grep "major version" | cut -d ' ' -f 5)
41+
if [[ "${version}" != "52" ]]; then
42+
echo "${class_file} is not compatible with Java 8."
43+
exit 1
44+
fi
45+
done
46+
echo "All class files are compatible with Java 8."

0 commit comments

Comments
 (0)