Social Media

Applying Eclipse formatting using Maven

I had an issue recently where a branch had been formatted by eclipse and made a merge from Trunk to Branch reasonably difficult. These things happen – so the solution was to find a plugin that would allow me to format both HEAD and Branch consistently outside of eclipse.

The first step was to export my eclipse preferences from eclipse –

Preferences > Java > Code Style > Formatter

Eclipse Preferences

Eclipse Preferences

The next step was to find a plugin that would apply these changes. I opted for formatter-maven-plugin

Then it was a matter of adding it to both master poms –

Then run the plugin on both branch and trunk –

Commit then continue with your merge

About the Author Martin Farrell

My name is Martin Farrell. I have almost 20 years Java experience. I specialize inthe Spring Framework and JEE. I’ve consulted to a range of businesses, and have provide Java and Spring mentoring and training. You can learn more at About

follow me on:

Leave a Comment: