从命令行根据 Eclipse 格式化配置文件进行验证
我正在寻找一种从命令行根据 Eclipse 代码格式化配置文件验证 Java 代码的方法。目标是创建一个 Mercurial 钩子,它拒绝任何与配置文件不匹配的提交。有办法做到这一点吗?
我知道可以从命令行调用 Eclipse 的格式化程序。我正在寻找的是只是验证(是/否)的东西。我想我可以使用格式化程序然后比较两者,但这似乎是一种笨拙的方法。
背景:我们想尝试这个的原因是因为我们目前由于格式差异而遇到了许多不必要的合并冲突。我们有一个使用多个 IDE 的环境,尽管官方只支持一个。我们希望强制执行官方配置文件,每个人都可以继续使用他们喜欢的工具,只要他们将其设置为正确格式化代码即可。
I'm looking for a way to verify Java code against an Eclipse code formatting profile from the command line. The goal is to create a Mercurial hook which rejects any commit that doesn't match the profile. Is there a way to do this?
I'm aware of the possibility to call Eclipse's formatter from the command line. What I'm looking for is something which just validates (yes/no). I guess I could use the formatter and then compare the two, but it seems like a clumsy approach.
Background: The reason we want to try this is because we currently get many unnecessary merge conflicts because of formatting differences. We have an environment where multiple IDE:s are used, although only one is officially supported. We want to enforce the official profile, and everyone can continue using the tools they prefer as long as they set it up to format the code correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简而言之,请按照以下步骤操作:
帮助您解决问题的技巧:
diff
实用程序:diff --text --quiet >/dev/null
,错误代码会告诉您您的情况寻找。In brief, follow those steps:
Tricks to help you out:
diff
utility:diff --text --quiet >/dev/null
, the error code will tell you what you're seeking for.