Fail build on Java code not formatted according to the ESCET formatter profile
As discussed here, Checkstyle does not catch all formatting mistakes. It would be good if the build fails if the code is not properly formatted. This prevents having to note these things via comments in reviews, as the build will catch it. Also, this prevents merging code with formatting mistakes to develop
, leading to unrelated changes when the code is later adapted and auto-formatted.
It seems the formatter-maven-plugin
can do exactly this, using its validate
goal. It is quite configurable as well. See https://code.revelc.net/formatter-maven-plugin/validate-mojo.html. It seems to be well-maintained, supporting all the latest Eclipse versions, see https://code.revelc.net/formatter-maven-plugin/eclipse-versions.html. We may need to choose the version that matches the Eclipse version that we use, to ensure consistency between formatting in the Eclipse ESCET development environment and the check in the build. The Eclipse upgrade instructions may need an extra item, to upgrade this plugin to match Eclipse upgrades.