In a maven project (backend java + frontend angular) I would like to add a coding style and format code automatically (many file types), with a git pre-commit hook for example or/and at compile time.
I found some code style related plugins:
But for each solution there is a problem (only java, without java linter, or opinionated). The .editorConfig seems the most complete configuration file, especially great for project which includes many different languages.
Sadly, the only plugin dealing with .editorconfig, editorconfig-maven-plugin, does not handle java, the plugin only comes with a yaml and xml linter.
Question 1: can we configure a Java linter for editorconfig-maven-plugin ? Any idea of a base to fork to write one ?
Question 2: Is there other tools to handle a java formatting based on .editorConfig ?
Any solution are welcome, even if not integrated with a maven plugin.
Unfortunately, the editorconfig-maven-plugin doesn't support Java at the moment: for now the plugin has support to enforce coding style rules for other languages such as XML and YAML.
There are different Maven plugins that support Java linting, like the maven-checkstyle-plugin or the PMD plugin.
If you're looking for a tool to handle Java formatting based on .editorConfig, there are several options:
Eclipse IDE along with the Eclipse Code Formatter plugin.
IntelliJ IDEA IDE with the EditorConfig plugin
separate command-line tools such as the JHipster code generator or the Jalopy code formatter. These tools can be easily integrated into Maven build process to automatically format Java code based on the .editorConfig rules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With