使用 eclipse 防止向 SVN 提交带有警告的文件
我有一个大型 Java 项目,有数千个编译警告。我想找到一种方法来防止开发人员提交带有警告的文件,这样所有警告就会逐渐消失。如果我提交一个带有编译错误的文件,Eclipse 会显示一条错误消息,但我找不到任何方法来对警告执行相同的操作。我发现的最接近的是提交警告检查器 http://commitwarncheck.sourceforge.net/ 但这不是真正集成到提交过程中,它只是提供一个视图。还有更好的解决办法吗?
I have a big Java project with thousands of compilation warnings. I would like to find a way to prevent developers commiting files with warnings, so gradually all warnings would disappear. If I commit a file with compilation error Eclipse displays an error message, but I couldnt find any way to do the same with warnings. The closest thing I found was The Commit warning checker http://commitwarncheck.sourceforge.net/ but that is not really integrated into the commit process, it just provides a view. Is there any better solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我看到有 2 个选项。首先,至少对于 Subclipse,有一个 Eclipse 首选项:Window / Preferences / Team / SVN / "提交资源时带有警告”。还有一个“错误”。两者都可以设置为“是”、“否”或“提示”。然而,这将要求您确保您的整个团队按照您的预期设置这些选项,并确保他们设置了所有其他 Eclipse 首选项以生成相同的错误/警告。
使用 Subclipse 1.6.18:
另一种选择是使用 SVN 提交钩子,本质上是持续集成(CI)过程的开始。您实际上可以检查一组有限的事情,然后允许/拒绝当时的提交,但我会开始担心提交性能。更好的选择可能是真正的 CI 流程,该流程运行构建(计划的,甚至可能是每次提交),并在检测到问题时通过电子邮件或其他方式向开发人员发出警报。
后面这个选项的复杂之处在于以脚本方式重复 Eclipse 构建 - 包括检测所有 Eclipse 配置的错误和警告。 (如果有人找到了这样做的好方法,请告诉我!Eclipse 提供了一个可编写脚本的选项来使用其代码格式化程序,但我还没有看到类似的选项来使用 Eclipse 提供的检查来检查错误/警告。)
否则,您可能最好开始迁移到 Checkstyle 和 FindBugs 在 Eclipse 内部和外部都同样有效。 (然而,与我自己的上述兴趣相关,我还没有找到一些工具的任何组合 - 包括这些工具 - 至少可以与 Eclipse 提供的相同检查相匹配。)将此与 Maven / m2e,提供一个通用的构建配置/过程可以由 Eclipse 和您的 CI 系统共享,并且您应该处于良好状态。
I see 2 options. First, at least with Subclipse, there's an Eclipse preference for this: Window / Preferences / Team / SVN / "Commit resources with warnings". There's one for "errors" as well. Both can be set to "Yes", "No", or "Prompt". However, this will require you to make sure that your entire team keeps these options set as you'd expect - as well as making sure that they have all of the other Eclipse preferences set to generate the same errors / warnings.
Using Subclipse 1.6.18:
Another option is to make use of SVN commit hooks, essentially the beginnings of a Continuous Integration (CI) process. You could actually check for a limited set of things, and allow/deny the commit at that time, but I'd start worrying about commit performance. A better option might be a true CI process that runs a build (either scheduled, or potentially even per-commit) - and emails or otherwise alerts the developer if an issue is detected.
The complication with this later option is repeating the Eclipse build - including detection of all Eclipse-configured errors and warnings - in a scripted manner. (If anyone finds a great way of doing this, please let me know! Eclipse provides a scriptable option for using its code formatter, but I've not seen a similar option for checking for errors / warnings using the checks provided by Eclipse.)
Otherwise, you'll probably be better off starting to migrate over to tools such as Checkstyle and FindBugs that work equally well both inside and outside of Eclipse. (However, relating back to my own interest above, I've not found any combination of a few tools - including these - that can at least match the same checks that Eclipse provides.) Combine this with Maven / m2e, providing a common build configuration / process that can be shared by both Eclipse and your CI system, and you should be in good shape.