Skip to content
This repository was archived by the owner on Oct 3, 2021. It is now read-only.

Commit e6c46b0

Browse files
Add CI check that checks formatting of Java sources
It uses google-java-format 1.9. Fixes #1170.
1 parent 42ecc6a commit e6c46b0

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

.gitlab-ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ java:
108108
tags:
109109
- privileged
110110

111+
java-format:
112+
stage: checks
113+
image: openjdk:11
114+
script: "java/check-format.sh"
115+
cache:
116+
key: "$CI_JOB_NAME"
117+
paths:
118+
- "java/*.jar"
119+
111120
.build-docker:
112121
image:
113122
name: gcr.io/kaniko-project/executor:debug

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ env:
99
- NAME="gcc-5" DOCKER_IMAGE=registry.gitlab.com/sosy-lab/software/sv-benchmarks/ci/gcc:5 COMMAND="gcc-5 -v --version; cd c; ./diff_ci.sh 'make -j2 CC=gcc-5 -C'"
1010
- NAME="clang-3.9" DOCKER_IMAGE=registry.gitlab.com/sosy-lab/software/sv-benchmarks/ci/clang:3.9 COMMAND="clang-3.9 -v --version; cd c; ./diff_ci.sh 'make -j2 CC=clang-3.9 -C'"
1111
- NAME="java" DOCKER_IMAGE=registry.gitlab.com/sosy-lab/software/sv-benchmarks/ci/java COMMAND="java/check-compile.sh"
12+
- NAME="java-format" DOCKER_IMAGE=openjdk:11 COMMAND="java/check-format.sh"
1213

1314
# Hint to TravisCI that we want to use their container infrastructure
1415
sudo: required

java/check-format.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -eu
3+
shopt -s globstar
4+
5+
GJF_VERSION="1.9"
6+
GJF_FILE="$(dirname "$0")/google-java-format-${GJF_VERSION}-all-deps.jar"
7+
8+
[ -f "${GJF_FILE}" ] || wget "https://github.com/google/google-java-format/releases/download/google-java-format-${GJF_VERSION}/$(basename "${GJF_FILE}")" -O "${GJF_FILE}"
9+
10+
echo "List of files that need to be reformatted with google-java-format ${GJF_VERSION}:"
11+
exec java -jar "${GJF_FILE}" --dry-run --set-exit-if-changed "$(dirname "$0")/"**/*.java

0 commit comments

Comments
 (0)