com.puppycrawl.tools.checkstyle

Class CheckStyleTask


public class CheckStyleTask
extends Task

An implementation of a ANT task for calling checkstyle. See the documentation of the task for usage.

Author:
Oliver Burn

Nested Class Summary

static class
CheckStyleTask.Formatter
Details about a formatter to be used.
static class
CheckStyleTask.FormatterType
Poor mans enumeration for the formatter types.
static class
CheckStyleTask.Listener
Represents a custom listener.
static class
CheckStyleTask.Property
Represents a property that consists of a key and value.

Method Summary

void
addFileset(FileSet aFS)
Adds a set of files (nested fileset attribute).
void
addFormatter(CheckStyleTask.Formatter aFormatter)
Add a formatter.
void
addProperty(CheckStyleTask.Property aProperty)
Add an override property.
Path
createClasspath()
void
execute()
Actually checks the files specified.
protected AuditListener[]
getListeners()
Return the list of listeners set in this task.
protected File[]
scanFileSets()
returns the list of files (full path name) to process.
void
setClasspath(Path aClasspath)
Set the class path.
void
setClasspathRef(Reference aClasspathRef)
Set the class path from a reference defined elsewhere.
void
setConfig(File aFile)
void
setConfigURL(URL aURL)
void
setFailOnViolation(boolean aFail)
void
setFailureProperty(String aPropertyName)
Tells this task to set the named property to "true" when there is a violation.
void
setFile(File aFile)
void
setMaxErrors(int aMaxErrors)
Sets the maximum number of errors allowed.
void
setMaxWarnings(int aMaxWarnings)
Sets the maximum number of warings allowed.
void
setPackageNamesFile(File aFile)
void
setProperties(File aProps)
Sets a properties file for use instead of individually setting them.

Method Details

addFileset

public void addFileset(FileSet aFS)
Adds a set of files (nested fileset attribute).

Parameters:
aFS - the file set to add


addFormatter

public void addFormatter(CheckStyleTask.Formatter aFormatter)
Add a formatter.

Parameters:
aFormatter - the formatter to add for logging.


addProperty

public void addProperty(CheckStyleTask.Property aProperty)
Add an override property.

Parameters:
aProperty - the property to add


createClasspath

public Path createClasspath()

Returns:
a created path for locating classes


execute

public void execute()
            throws BuildException
Actually checks the files specified. All errors are reported to System.out. Will fail if any errors occurred.


getListeners

protected AuditListener[] getListeners()
            throws ClassNotFoundException,
                   InstantiationException,
                   IllegalAccessException,
                   IOException
Return the list of listeners set in this task.

Returns:
the list of listeners.


scanFileSets

protected File[] scanFileSets()
returns the list of files (full path name) to process.

Returns:
the list of files included via the filesets.


setClasspath

public void setClasspath(Path aClasspath)
Set the class path.

Parameters:
aClasspath - the path to locate classes


setClasspathRef

public void setClasspathRef(Reference aClasspathRef)
Set the class path from a reference defined elsewhere.

Parameters:
aClasspathRef - the reference to an instance defining the classpath


setConfig

public void setConfig(File aFile)

Parameters:
aFile - the configuration file to use


setConfigURL

public void setConfigURL(URL aURL)

Parameters:
aURL - the URL of the configuration to use


setFailOnViolation

public void setFailOnViolation(boolean aFail)

Parameters:
aFail - whether to fail if a violation is found


setFailureProperty

public void setFailureProperty(String aPropertyName)
Tells this task to set the named property to "true" when there is a violation.

Parameters:
aPropertyName - the name of the property to set in the event of an failure.


setFile

public void setFile(File aFile)

Parameters:
aFile - the file to be checked


setMaxErrors

public void setMaxErrors(int aMaxErrors)
Sets the maximum number of errors allowed. Default is 0.

Parameters:
aMaxErrors - the maximum number of errors allowed.


setMaxWarnings

public void setMaxWarnings(int aMaxWarnings)
Sets the maximum number of warings allowed. Default is Integer.MAX_VALUE.

Parameters:
aMaxWarnings - the maximum number of warnings allowed.


setPackageNamesFile

public void setPackageNamesFile(File aFile)

Parameters:
aFile - the package names file to use


setProperties

public void setProperties(File aProps)
Sets a properties file for use instead of individually setting them.

Parameters:
aProps - the properties File to use