Java CheckStyle usage

独自空忆成欢 提交于 2019-12-14 01:27:07

问题


I'd like to write my own Check using CheckStyle and incorporate this in my ant build.xml. The documentation doesn't seem to provide detailed instructions on how to do so. Does anyone have experience doing this, and if so, can they provide a HelloWorldCheck example along with the changes one needs in their build.xml to create a target that runs this?

Here is a reference to my question on their sourceforge mail dist


回答1:


Here is an example for writing an ant task to run checkstyle.

You should look at the available checks to see if there is already a check that fulfills your requirement. If not, the following guide should have enough information to get you started.




回答2:


Below is a 'HelloWorld' style example although it is written for Maven and not Ant.

For an Ant build you would build the BlundellCheckstyle as a jar and package it in your /libs/ folder. The configuration is just the same as below and the command to run checkstyle from the command line would work a treat. Using the AntTask example it looks pretty much like the Maven config and wouldn't take much to change it.

http://blog.blundell-apps.com/create-your-own-checkstyle-check/

and source code here:

https://github.com/blundell/CreateYourOwnCheckStyleCheck



来源:https://stackoverflow.com/questions/6590429/java-checkstyle-usage

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