Maven Eclipse 格式化程序无法按预期工作
我们想要使用maven formatter,它使用eclipse的formatter.xml
文件来格式化我们项目的java代码。我们尝试过 Maven java formatter 插件,Maven eclipse 格式 和 maven eclipse 插件。所有插件都以不同的方式格式化代码,并且该格式化与 eclipse 格式化生成的格式化文件有很大不同。
Maven java formatter 插件最接近 eclipse 格式化,但当该行包含通用参数时,它无法将行分割为指定长度。另外,javadoc 格式与 eclipse 不同。
如果有人使用过带有 Maven 的 Eclipse 格式化程序,并且其工作原理与 Eclipse 内部格式化程序类似,请告诉我。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我对 maven-java-formatter-plugin 也有类似的问题。我已经在 https://github 发布了一个可以解决 Eclipse 3.7.1 SR1 问题的分支.com/benalexau/maven-java-formatter-plugin/ 欢迎您使用。请注意,我已记录 http://code.google.com/p/maven-java-formatter-plugin/issues/detail?id=18&thanks=18&ts=1324185588 针对原始项目如果运气好的话,可以合并这些更改。 HTH。
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.
您可以使用以下命令应用解决方法。
net.revelc.code.formatter:formatter-maven-plugin:2.10.0:format
。net.revelc.code.formatter:formatter-maven-plugin:2.10.0:validate
。在eclipse中,您可以如下所示配置maven目标。
You can apply a workaround using the below commands.
net.revelc.code.formatter:formatter-maven-plugin:2.10.0:format
.net.revelc.code.formatter:formatter-maven-plugin:2.10.0:validate
.In eclipse, you can configure the maven goal as shown below.