Amit Verma
Amit Verma

Reputation: 167

Maven eclipse formatter doesn't work as expected

We want to use maven formatter which uses eclipse's formatter.xml file to format java code of our project. We have tried Maven java formatter plugin, Maven eclipse format and maven eclipse plugin. All the plugins are formatting code differently and that formatting is very much different from formatted file produced by eclipse formatting.

Maven java formatter plugin is closest to eclipse formatting but it is unable to split line to specified length when that line contains generic parameters. Also javadoc formatting is not same in it as compared to eclipse.

If any one has used eclipse formatter with maven and if that works similar to eclipse internal formatter please let me know about it.

Upvotes: 3

Views: 3210

Answers (2)

Kishor K
Kishor K

Reputation: 1635

You can apply a workaround using the below commands.

  • To format: net.revelc.code.formatter:formatter-maven-plugin:2.10.0:format.
  • To validate: net.revelc.code.formatter:formatter-maven-plugin:2.10.0:validate.

In eclipse, you can configure the maven goal as shown below.

enter image description here

Upvotes: 0

Ben Alex
Ben Alex

Reputation: 1529

I had a similar issue with maven-java-formatter-plugin. I have published a fork that resolves it for Eclipse 3.7.1 SR1 at https://github.com/benalexau/maven-java-formatter-plugin/ which you are welcome to use. Note I have logged http://code.google.com/p/maven-java-formatter-plugin/issues/detail?id=18&thanks=18&ts=1324185588 against the original project to merge these changes with a little luck. HTH.

Upvotes: 1

Related Questions