patch to control ANT stopping the build on violations

This commit is contained in:
Oliver Burn 2001-10-31 13:06:28 +00:00
parent 030798a11d
commit 403a3f70a3
4 changed files with 23 additions and 2 deletions

View File

@ -1,3 +1,10 @@
2001-10-31 Oliver Burn <checkstyle@puppycrawl.com>
* src/checkstyle/com/puppycrawl/tools/checkstyle/CheckStyleTask.java:
Included patch to control whether the build fails on violation errors.
From Michael McDougall [ mmcdouga _AT_ saul _DOT_ cis _DOT_ upenn
_DOT_ edu]
2001-10-31 Oliver Burn <checkstyle@puppycrawl.com>
* src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java, src/checkstyle/com/puppycrawl/tools/checkstyle/StringArrayReader.java:

View File

@ -122,6 +122,11 @@ This task is included in the checkstyle distribution.</p>
<td valign="top">Specifies whether to ignore checking braces. Defaults to <span class="default">&quot;false&quot;</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">&quot;true&quot;</span>.</td>
<td align="center" valign="top">No</td>
</tr>
</table>
<h3>Examples</h3>

View File

@ -51,7 +51,7 @@ div.tip {margin-left : 5%;margin-right : 5%;padding-left: 2%; padding-right: 2%;
<h2>Getting checkstyle</h2>
<p>Binary and source distributions are from <a href="http://www.puppycrawl.com/checkstyle">http://www.puppycrawl.com/checkstyle</a>.</p>
<p>Binary and source distributions are from <a href="http://checkstyle.sourceforge.net/">http://checkstyle.sourceforge.net/</a>.</p>
<p>Source code is stored under CVS at <a href="http://sourceforge.net">SourceForge</a>. The project page is <a href="http://sourceforge.net/projects/checkstyle">http://sourceforge.net/projects/checkstyle</a>.</p>

View File

@ -49,6 +49,9 @@ public class CheckStyleTask
/** name of file to check **/
private String mFileName;
/** whether to fail build on violations **/
private boolean mFailOnViolation = true;
/** contains the filesets to process **/
private final List mFileSets = new ArrayList();
@ -189,6 +192,12 @@ public class CheckStyleTask
}
}
/** @param aFail whether to fail if a violation is found **/
public void setFailOnViolation(boolean aFail)
{
mFailOnViolation = aFail;
}
/** @param aNum **/
public void setHeaderIgnoreLine(int aNum)
{
@ -264,7 +273,7 @@ public class CheckStyleTask
}
}
if (numErrs > 0) {
if ((numErrs > 0) && mFailOnViolation) {
throw new BuildException("Got " + numErrs + " errors.", location);
}
}