This task runs checkstyle over specified Java files. The task has been tested using ANT 1.3. The latest version of checkstyle can be found at http://www.puppycrawl.com/checkstyle. This task is included in the checkstyle distribution.
The easiest way is to include checkstyle-all-@@VERSION@@.jar in the classpath. This contains all the classes required to run checkstyle. Alternatively, you must include the following in the classpath:
To use the task in a build file, you will need the following taskdef declaration:
<taskdef name="checkstyle"
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask"/>
| Attribute | Description | Required |
| file | File to run checkstyle on. | One of either file or at least one nested fileset element |
| allowTabs | Indicates whether to allow tabs. Defaults to "false". | No |
| allowProtected | Indicates whether to allow protected data. Defaults to "false". | No |
| allowNoAuthor | Indicates whether to allow no @author tag to be defined for class and interface Javadoc comments. Defaults to "false". | No |
| maxLineLen | Specifies the maximum line length. Default value is defined here. | No |
| memberPattern | Specifies the regular expression to match against member variables. Default value is defined here. | No |
| publicMemberPattern | Specifies the regular expression to match against public member variables. Default value is defined here. | No |
| paramPattern | Specifies the regular expression to match against parameters. Default value is defined here. | No |
| constPattern | Specifies the regular expression to match against static/final variables. Default value is defined here. | No |
| staticPattern | Specifies the regular expression to match against static variables. Default value is defined here. | No |
| typePattern | Specifies the regular expression to match against type names. Default value is defined here. | No |
| headerFile | Specifies the file containing the header lines. Default is to not check. | No |
| headerIgnoreLine | Specifies the line in the header to ignore when comparing. Default it to not ignore any line. | No |
| relaxJavadoc | Specifies whether to relax checking Javadoc comments. Defaults to "false". | No |
| ignoreImports | Specifies whether to ignore checking import statements. Defaults to "false". | No |
| ignoreWhitespace | Specifies whether to ignore checking whitespace. Defaults to "false". | No |
| ignoreBraces | Specifies whether to ignore checking braces. Defaults to "false". | No |
| failOnViolation | Specifies whether the build will continue even if there are violations. Defaults to "true". | No |
Run checkstyle on a single file
<checkstyle file="Check.java"/>
Run checkstyle on a set of Java files in directory
<checkstyle>
<fileset dir="src/checkstyle" includes="**/*.java"/>
</checkstyle>
Run checkstyle on a set of Java files and allow tabs
<checkstyle allowTabs="yes">
<fileset dir="src/checkstyle" includes="**/*.java"/>
</checkstyle>
Run checkstyle on a set of Java files and disable pattern matching
<checkstyle allowTabs="yes"
paramPattern="."
constPattern="."
staticPattern="."
memberPattern=".">
<fileset dir="src/checkstyle" includes="**/*.java"/>
</checkstyle>
Copyright © 2001 Oliver Burn. All rights Reserved.