|
Making an Ant task
Checkstyle can also be integrated with Ant task. Take the
following configuration sample for the Ant task and add it to
your build file. Generally, it is a good practice so that Java
files are checked at the build time for the coding standard. Any
deviation from the defined coding standard will stop the build
process.
<taskdef resource="checkstyletask.properties"
classpath="/path/to/checkstyle-all-3.1.jar"/> <checkstyle
config="config/mychecks.xml"> <fileset dir="src"
includes="**/*.java"/> <formatter type="plain"/>
<formatter type="xml" toFile="build/checkstyle_errors.xml"/>
</checkstyle>
Executing this ant task will produce the plain error report to
the console and generate an xml file to show the error reports.
The advantage of having an XML file is that you can apply
stylesheets to it, to generate HTML formatted output. Also, you
can migrate the error report to any other system.
Conclusion
Checkstyle is a valuable tool. I truly hope this article will
help you find some interest in incorporating Checkstyle in your
project. If you want more details, the Checkstyle website has a great
deal of information in it. Employing coding standards just got a little
easier
Samudra Gupta has six
years of Java related application development experience. He has
been involved in various research based projects in Java
including e-commerce based and application design and
development projects. He is based in the United Kingdom. In his
free time, he is a columnist in different Java Magazines and
Journals and loves to play contract bridge.
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.
|