201 lines
9.2 KiB
HTML
201 lines
9.2 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
|
|
<html>
|
|
<head>
|
|
<title>checkstyle ANT Task</title>
|
|
<style>
|
|
span.default {white-space: nowrap;font-family: monospace;font-size: x-small;}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<h2><a name="checkstyle">checkstyle ANT Task</a></h2>
|
|
<h3>Description</h3>
|
|
|
|
<p>This task runs checkstyle over specified Java files. The task has been tested using ANT 1.4.1. The latest version of checkstyle can be found at <a href="http://checkstyle.sourceforge.net/">http://checkstyle.sourceforge.net/</a>.
|
|
This task is included in the checkstyle distribution.</p>
|
|
|
|
<h3>Installation</h3>
|
|
<p>The easiest way is to include <span class="default">checkstyle-all-1.4.jar</span> in the classpath. This contains all the classes required to run checkstyle. Alternatively, you must include the following in the classpath:</p>
|
|
<ol>
|
|
<li><span class="default">checkstyle-1.4.jar</span></li>
|
|
<li>ANTLR 2.7.1 classes. <span class="default">antlr.jar</span> is included in the distribution.</li>
|
|
<li>Jakarta Regexp 1.2 classes. <span class="default">jakarta-regexp-1.2.jar</span> is included in the distribution.</li>
|
|
</ol>
|
|
|
|
<p>To use the task in a build file, you will need the following <code>taskdef</code> declaration:</p>
|
|
<pre>
|
|
<taskdef name="checkstyle"
|
|
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask"/>
|
|
</pre>
|
|
|
|
|
|
<h3>Parameters</h3>
|
|
<table border="1" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td valign="top"><b>Attribute</b></td>
|
|
<td valign="top"><b>Description</b></td>
|
|
<td valign="top"><b>Required</b></td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">file</td>
|
|
<td valign="top">File to run checkstyle on.</td>
|
|
<td align="center" valign="top">One of either <i>file</i> or at least one nested <i>fileset</i> element</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">allowTabs</td>
|
|
<td valign="top">Indicates whether to allow tabs. Defaults to <span class="default">"false"</span>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">allowProtected</td>
|
|
<td valign="top">Indicates whether to allow protected data. Defaults to <span class="default">"false"</span>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">allowNoAuthor</td>
|
|
<td valign="top">Indicates whether to allow no <span class="default">@author</span> tag to be defined for class and interface Javadoc comments. Defaults to <span class="default">"false"</span>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">maxLineLen</td>
|
|
<td valign="top">Specifies the maximum line length. Default value is defined <a href="index.html#length">here</a>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">ignoreImportLen</td>
|
|
<td valign="top">Specifies whether to ignore the maximum line length for <span class="code">import</span> statements. Defaults to <span class="default">"false"</span>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">maxMethodLen</td>
|
|
<td valign="top">Specifies the maximum method length. Default value is defined <a href="index.html#methodLength">here</a>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">maxConstructorLen</td>
|
|
<td valign="top">Specifies the maximum constructor length. Default value is defined <a href="index.html#constructorLength">here</a>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">maxFileLen</td>
|
|
<td valign="top">Specifies the maximum file length. Default value is defined <a href="index.html#fileLength">here</a>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td valign="top">memberPattern</td>
|
|
<td valign="top">Specifies the regular expression to match against member variables. Default value is defined <a href="index.html#varformat">here</a>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">publicMemberPattern</td>
|
|
<td valign="top">Specifies the regular expression to match against public member variables. Default value is defined <a href="index.html#fieldformat">here</a>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">paramPattern</td>
|
|
<td valign="top">Specifies the regular expression to match against parameters. Default value is defined <a href="index.html#paramformat">here</a>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">constPattern</td>
|
|
<td valign="top">Specifies the regular expression to match against static/final variables. Default value is defined <a href="index.html#varformat">here</a>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">staticPattern</td>
|
|
<td valign="top">Specifies the regular expression to match against static variables. Default value is defined <a href="index.html#varformat">here</a>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">typePattern</td>
|
|
<td valign="top">Specifies the regular expression to match against type names. Default value is defined <a href="index.html#typeformat">here</a>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">headerFile</td>
|
|
<td valign="top">Specifies the file containing the header lines. Default is to not check.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">headerIgnoreLine</td>
|
|
<td valign="top">Specifies the line in the header to ignore when comparing. Default it to not ignore any line.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">javadocScope</td>
|
|
<td valign="top">Specifies the visibility scope where javadoc comments are checked. Valid values are <span class="default">"nothing"</span>, <span class="default">"public"</span>, <span class="default">"protected"</span>, <span class="default">"package"</span>, <span class="default">"private"</span> and <span class="default">"anoninner"</span>. Defaults to <span class="default">"private"</span>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">ignoreImports</td>
|
|
<td valign="top">Specifies whether to ignore checking import statements. Defaults to <span class="default">"false"</span>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">ignoreWhitespace</td>
|
|
<td valign="top">Specifies whether to ignore checking whitespace. Defaults to <span class="default">"false"</span>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">ignoreCastWhitespace</td>
|
|
<td valign="top">Specifies whether to ignore checking for whitespace after a cast. Defaults to <span class="default">"false"</span>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">ignoreBraces</td>
|
|
<td valign="top">Specifies whether to ignore checking braces. Defaults to <span class="default">"false"</span>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">failOnViolation</td>
|
|
<td valign="top">Specifies whether the build will continue even if there are violations. Defaults to <span class="default">"true"</span>.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">cacheFile</td>
|
|
<td valign="top">Specifies the name of a file that can be used to cache details of files that pass checkstyle. This can signicantly increase the speed of checkstyle on successive runs.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<p>Older versions of the checkstyle task supported the boolean parameters relaxJavadoc and ignoreJavadoc. These parameters have been removed because they were conflicting and the semantics of relaxJavadoc was not clearly specified. The two parameters have been replaced by the javadocScope parameter. Instead of ignoreJavadoc="true" you can now use javadocScope="nothing". The behaviour of relaxJavadoc="true" is roughly the same as javadocScope="protected".</p>
|
|
|
|
<h3>Examples</h3>
|
|
<p><b>Run checkstyle on a single file</b></p>
|
|
<pre>
|
|
<checkstyle file="Check.java"/>
|
|
</pre>
|
|
|
|
<p><b>Run checkstyle on a set of Java files in directory</b></p>
|
|
<pre>
|
|
<checkstyle>
|
|
<fileset dir="src/checkstyle" includes="**/*.java"/>
|
|
</checkstyle>
|
|
</pre>
|
|
|
|
<p><b>Run checkstyle on a set of Java files and allow tabs</b></p>
|
|
<pre>
|
|
<checkstyle allowTabs="yes">
|
|
<fileset dir="src/checkstyle" includes="**/*.java"/>
|
|
</checkstyle>
|
|
</pre>
|
|
|
|
<p><b>Run checkstyle on a set of Java files and disable pattern matching</b></p>
|
|
<pre>
|
|
<checkstyle allowTabs="yes"
|
|
paramPattern="."
|
|
constPattern="."
|
|
staticPattern="."
|
|
memberPattern=".">
|
|
<fileset dir="src/checkstyle" includes="**/*.java"/>
|
|
</checkstyle>
|
|
</pre>
|
|
|
|
<hr>
|
|
<p align="center">Copyright © 2001 Oliver Burn. All rights Reserved.</p>
|
|
</body>
|
|
</html>
|