Class CheckstyleAntTask
- java.lang.Object
-
- org.apache.tools.ant.ProjectComponent
-
- org.apache.tools.ant.Task
-
- com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask
-
- All Implemented Interfaces:
java.lang.Cloneable
public class CheckstyleAntTask extends org.apache.tools.ant.Task
An implementation of a ANT task for calling checkstyle. See the documentation of the task for usage.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CheckstyleAntTask.Formatter
Details about a formatter to be used.static class
CheckstyleAntTask.FormatterType
Poor mans enumeration for the formatter types.static class
CheckstyleAntTask.Listener
Represents a custom listener.static class
CheckstyleAntTask.Property
Represents a property that consists of a key and value.
-
Constructor Summary
Constructors Constructor Description CheckstyleAntTask()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFileset(org.apache.tools.ant.types.FileSet fileSet)
Adds set of files (nested fileset attribute).void
addFormatter(CheckstyleAntTask.Formatter formatter)
Add a formatter.void
addPath(org.apache.tools.ant.types.Path path)
Adds a path.void
addProperty(CheckstyleAntTask.Property property)
Add an override property.org.apache.tools.ant.types.Path
createClasspath()
Creates classpath.void
execute()
protected java.util.List<java.io.File>
scanFileSets()
Returns the list of files (full path name) to process.void
setClasspath(org.apache.tools.ant.types.Path classpath)
Set the class path.void
setClasspathRef(org.apache.tools.ant.types.Reference classpathRef)
Set the class path from a reference defined elsewhere.void
setConfig(java.lang.String configuration)
Sets configuration file.void
setExecuteIgnoredModules(boolean omit)
Sets flag - whether to execute ignored modules.void
setFailOnViolation(boolean fail)
Sets flag - whether to fail if a violation is found.void
setFailureProperty(java.lang.String propertyName)
Tells this task to write failure message to the named property when there is a violation.void
setFile(java.io.File file)
Sets file to be checked.void
setMaxErrors(int maxErrors)
Sets the maximum number of errors allowed.void
setMaxWarnings(int maxWarnings)
Sets the maximum number of warnings allowed.void
setProperties(java.io.File props)
Sets a properties file for use instead of individually setting them.-
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
-
-
-
-
Method Detail
-
setFailureProperty
public void setFailureProperty(java.lang.String propertyName)
Tells this task to write failure message to the named property when there is a violation.- Parameters:
propertyName
- the name of the property to set in the event of an failure.
-
setFailOnViolation
public void setFailOnViolation(boolean fail)
Sets flag - whether to fail if a violation is found.- Parameters:
fail
- whether to fail if a violation is found
-
setMaxErrors
public void setMaxErrors(int maxErrors)
Sets the maximum number of errors allowed. Default is 0.- Parameters:
maxErrors
- the maximum number of errors allowed.
-
setMaxWarnings
public void setMaxWarnings(int maxWarnings)
Sets the maximum number of warnings allowed. Default isInteger.MAX_VALUE
.- Parameters:
maxWarnings
- the maximum number of warnings allowed.
-
addPath
public void addPath(org.apache.tools.ant.types.Path path)
Adds a path.- Parameters:
path
- the path to add.
-
addFileset
public void addFileset(org.apache.tools.ant.types.FileSet fileSet)
Adds set of files (nested fileset attribute).- Parameters:
fileSet
- the file set to add
-
addFormatter
public void addFormatter(CheckstyleAntTask.Formatter formatter)
Add a formatter.- Parameters:
formatter
- the formatter to add for logging.
-
addProperty
public void addProperty(CheckstyleAntTask.Property property)
Add an override property.- Parameters:
property
- the property to add
-
setClasspath
public void setClasspath(org.apache.tools.ant.types.Path classpath)
Set the class path.- Parameters:
classpath
- the path to locate classes
-
setClasspathRef
public void setClasspathRef(org.apache.tools.ant.types.Reference classpathRef)
Set the class path from a reference defined elsewhere.- Parameters:
classpathRef
- the reference to an instance defining the classpath
-
createClasspath
public org.apache.tools.ant.types.Path createClasspath()
Creates classpath.- Returns:
- a created path for locating classes
-
setFile
public void setFile(java.io.File file)
Sets file to be checked.- Parameters:
file
- the file to be checked
-
setConfig
public void setConfig(java.lang.String configuration)
Sets configuration file.- Parameters:
configuration
- the configuration file, URL, or resource to use- Throws:
org.apache.tools.ant.BuildException
- when config was already set
-
setExecuteIgnoredModules
public void setExecuteIgnoredModules(boolean omit)
Sets flag - whether to execute ignored modules.- Parameters:
omit
- whether to execute ignored modules
-
setProperties
public void setProperties(java.io.File props)
Sets a properties file for use instead of individually setting them.- Parameters:
props
- the properties File to use
-
execute
public void execute()
- Overrides:
execute
in classorg.apache.tools.ant.Task
-
scanFileSets
protected java.util.List<java.io.File> scanFileSets()
Returns the list of files (full path name) to process.- Returns:
- the list of files included via the filesets.
-
-