问题
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