-
Notifications
You must be signed in to change notification settings - Fork 24
Description
To enforce code consistency, and avoid formatting comments in reviews, we want to adopt a code formatting step during the build to enforce coding standards.
There are various approaches to this, pure checking or even rewriting code files. @elmuerte thinks rewriting solution would be the best for incidental contributors and I agree. They just have to mvn compile for the code to be reformatted. There are bunch of opinionated maven plugins or some more configurable plugins.
@elmuerte would go for revelc's plugins which takes Eclipse formatting configuration files:
- https://code.revelc.net/formatter-maven-plugin/
- https://code.revelc.net/impsort-maven-plugin/ (for import sorting)
A good alternative is spotless which almost contains the kitchen sink. It also supports the Eclipse formatting configuration file, or you could opt for Google's or Palantir's rules. It also includes an import order step, and some others. It takes a bit more effort to configure.
Either way. We want to include the format(/sort)/apply goals as part of the process sources step. In the github action we want to perform the check action before actually compiling the code so that you know the PR contents is properly formatted.