Prevent commiting files to SVN with warnings using eclipse

独自空忆成欢 提交于 2020-01-14 12:33:17

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/8618678/prevent-commiting-files-to-svn-with-warnings-using-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!