We are working on a legacy app code base and doing incremental development to improve its code quality.
When we ran the maven checkstyle goal on the project we got tons of errors. To address the issues incrementally, we are taking an approach to run checkstyle only on the files which each developer is editing and before committing.
The options I ran into while search for a solution are pre-commit hooks
which executes a maven goal before committing the code.
References:
https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
https://hdpe.me/post/maven-checkstyle-pre-commit-hook/
The disadvantage of the above approach is it cannot be enforced on each developers machine. Since the hooks are not uploaded into the repository. We have our own limitations(team politics) in implementing server side hooks.
IntelliJ checkstyle plugin has the exact functionality which I am looking for (Check All Modified Files).
But, not all developers in our team use IntelliJ and It cannot be enforced during the build process.
I guess what I am trying to ask is, is there a way to trigger the pre-commit hook(logic) as a maven goal?