Skip to content

Add Code Formatting to the Project Build #447

@pmckeown

Description

@pmckeown

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions