From 403a3f70a368717081aeb87fedcaf0504dee61fe Mon Sep 17 00:00:00 2001
From: Oliver Burn
Date: Wed, 31 Oct 2001 13:06:28 +0000
Subject: [PATCH] patch to control ANT stopping the build on violations
---
ChangeLog | 7 +++++++
docs/anttask.html | 5 +++++
docs/index.html | 2 +-
.../puppycrawl/tools/checkstyle/CheckStyleTask.java | 11 ++++++++++-
4 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c6f18018d..200bb2a35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2001-10-31 Oliver Burn
+
+ * 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
* src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java, src/checkstyle/com/puppycrawl/tools/checkstyle/StringArrayReader.java:
diff --git a/docs/anttask.html b/docs/anttask.html
index 69af375ee..b1bd2772b 100644
--- a/docs/anttask.html
+++ b/docs/anttask.html
@@ -122,6 +122,11 @@ This task is included in the checkstyle distribution.
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 |
+
Examples
diff --git a/docs/index.html b/docs/index.html
index d28074d29..5e6bd2f1c 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -51,7 +51,7 @@ div.tip {margin-left : 5%;margin-right : 5%;padding-left: 2%; padding-right: 2%;
Getting checkstyle
-Binary and source distributions are from http://www.puppycrawl.com/checkstyle.
+Binary and source distributions are from http://checkstyle.sourceforge.net/.
Source code is stored under CVS at SourceForge. The project page is http://sourceforge.net/projects/checkstyle.
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/CheckStyleTask.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/CheckStyleTask.java
index 6ce69d1a4..37a71b035 100644
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/CheckStyleTask.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/CheckStyleTask.java
@@ -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);
}
}