Skip to content

Fromatter plugin tips

Dmitrii Bocharov edited this page Dec 18, 2017 · 1 revision

This plugin allows formatting java source code using the Eclipse code formatter. Plugin main page: http://code.revelc.net/formatter-maven-plugin/.

We are using the default eclipse formatting settings (at least it's true while i'm writing it). All settings are a collected in eclipse-formatter.xml file. At the moment of writing it, no additional actions are required to format the files correctly with Ctrl-Shift-F shortcut. However, most likely the file is changed and must be imported to your Eclipse for correct formatting with the Ctrl-Shift-F shortcut. To do this go to: Window -> Preferences, on the left choose Java -> Code Style -> Formatter, then on the right click Import and choose eclipse-formatter.xml.

The plugin has 2 main goals: format & validate.

The format goal will format all source files according to the eclipse-formatter.xml file. The validate goal will only validate all source files and will fail the build if any of the files are not formatted.

If file is formatted or not is decided by comparison of the sha512 hash of the content and the hash of the formatting content.