Scott just separated the spotless check from the Java unit test precommit job, so you get faster feedback on spotless errors.
I wondered if there was a good place to just always reformat, and whether it was fast enough to be OK. The answer is yes, and yes.
You can set up a git precommit hook to always autoformat code, by putting this in .git/hooks/pre-commit and setting the executable bit.
Then testing the time:
- From a fresh checkout ./gradlew spotlessJavaApply took 24s configuration and 49s spotlessApply
- Then I modified one file in nexmark, messed up the formatting, and committed
- The re-run took 1s in configuration and 4s in spotlessApply
So this will add ~5s of waiting each time you `git commit`. You can decide if it is worth it to you. If you are a "push a bunch of commits to be squashed" GitHub user, you could amortize it by making it a pre-push hook that adds a spotless commit (`git commit --fixup HEAD`).