Skip to content

Commit b482661

Browse files
committed
ci: use google-java-format native binary for local lint
Replaces the slow Gradle-based spotlessCheck with google-java-format native binary (~42ms) for changed files only. Also checks license headers. CI still runs the full spotlessCheck via Gradle.
1 parent 733f571 commit b482661

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

mise.toml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ java = "temurin-25.0.1+8.0.LTS"
33
lychee = "0.22.0"
44
node = "24.14.0"
55
"npm:renovate" = "43.66.3"
6+
"ubi:google/google-java-format" = "1.34.1"
67

78
[env]
89
RENOVATE_TRACKED_DEPS_EXCLUDE="github-actions,github-runners"
@@ -30,13 +31,25 @@ file = "https://raw.githubusercontent.com/grafana/flint/8a39d96e17327c54974623b2
3031
description = "Install native lint tools matching the pinned super-linter version"
3132
file = "https://raw.githubusercontent.com/grafana/flint/8a39d96e17327c54974623b252eb5260d67ed68a/tasks/setup/native-lint-tools.sh" # v0.9.1
3233

33-
[tasks."lint:spotless"]
34-
description = "Check Java formatting with Spotless"
35-
run = "./gradlew spotlessCheck"
34+
[tasks."lint:java"]
35+
description = "Check Java formatting and license headers (changed files only)"
36+
run = """
37+
files=$(git diff --name-only --diff-filter=d origin/main...HEAD -- '*.java')
38+
[ -z "$files" ] && exit 0
39+
failed=0
40+
for f in $files; do
41+
if ! head -4 "$f" | grep -q "SPDX-License-Identifier: Apache-2.0"; then
42+
echo "Missing license header: $f"
43+
failed=1
44+
fi
45+
done
46+
google-java-format --dry-run --set-exit-if-changed $files || failed=1
47+
exit $failed
48+
"""
3649

3750
[tasks."lint:fast"]
3851
description = "Run fast lints (no Renovate)"
39-
depends = ["lint:super-linter", "lint:links", "lint:spotless"]
52+
depends = ["lint:super-linter", "lint:links", "lint:java"]
4053

4154
[tasks.native-lint]
4255
description = "Run lints natively (no container)"
@@ -56,4 +69,8 @@ depends = ["lint:fast", "lint:renovate-deps"]
5669

5770
[tasks.fix]
5871
description = "Auto-fix lint issues and regenerate tracked deps"
59-
run = ["./gradlew spotlessApply", "AUTOFIX=true mise run lint"]
72+
run = """
73+
files=$(git diff --name-only --diff-filter=d origin/main...HEAD -- '*.java')
74+
[ -n "$files" ] && google-java-format -i $files
75+
AUTOFIX=true mise run lint
76+
"""

0 commit comments

Comments
 (0)