Package edu.umd.cs.findbugs.anttask
Class FindBugsTask
- java.lang.Object
-
- org.apache.tools.ant.ProjectComponent
-
- org.apache.tools.ant.Task
-
- edu.umd.cs.findbugs.anttask.AbstractFindBugsTask
-
- edu.umd.cs.findbugs.anttask.FindBugsTask
-
- All Implemented Interfaces:
java.lang.Cloneable
public class FindBugsTask extends AbstractFindBugsTask
FindBugs in Java class files. This task can take the following arguments:- adjustExperimental (boolean default false)
- adjustPriority (passed to -adjustPriority)
- applySuppression (exclude any warnings that match a suppression filter supplied in a project file)
- auxAnalyzepath (class, jar, zip files or directories containing classes to analyze)
- auxClasspath (classpath or classpathRef)
- baselineBugs (xml file containing baseline bugs)
- class (class, jar, zip or directory containing classes to analyze)
- classpath (classpath for running FindBugs)
- conserveSpace (boolean - default false)
- debug (boolean default false)
- effort (enum min|default|max)
- excludeFilter (filter filename)
- excludePath (classpath or classpathRef to filters)
- failOnError (boolean - default false)
- home (findbugs install dir)
- includeFilter (filter filename)
- includePath (classpath or classpathRef to filters)
- maxRank (maximum rank issue to be reported)
- jvm (Set the command used to start the VM)
- jvmargs (any additional jvm arguments)
- omitVisitors (collection - comma separated)
- onlyAnalyze (restrict analysis to find bugs to given comma-separated list of classes and packages - See the textui argument description for details)
- output (enum text|xml|xml:withMessages|html - default xml)
- outputFile (name of output file to create)
- nested (boolean default true)
- noClassOk (boolean default false)
- pluginList (list of plugin Jar files to load)
- projectFile (project filename)
- projectName (project name, for display in generated HTML)
- userPreferencesFile (user preferences filename)
- quietErrors (boolean - default false)
- relaxed (boolean - default false)
- reportLevel (enum experimental|low|medium|high)
- sort (boolean default true)
- stylesheet (name of stylesheet to generate HTML: default is "default.xsl")
- systemProperty (a system property to set)
- timestampNow (boolean - default false)
- visitors (collection - comma separated)
- chooseVisitors (selectively enable/disable visitors)
- workHard (boolean default false)
- setSetExitCode (boolean default true)
Of these arguments, the home is required. projectFile is required if nested <class> or <auxAnalyzepath> elements are not specified. the <class> tag defines the location of either a class, jar file, zip file, or directory containing classes.
- Since:
- Ant 1.5
- Version:
- $Revision: 1.56 $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FindBugsTask.ClassLocation
-
Nested classes/interfaces inherited from class edu.umd.cs.findbugs.anttask.AbstractFindBugsTask
AbstractFindBugsTask.SystemProperty
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
adjustExperimental
private java.lang.String
adjustPriority
private boolean
applySuppression
private org.apache.tools.ant.types.Path
auxAnalyzepath
private org.apache.tools.ant.types.Path
auxClasspath
private java.io.File
baselineBugs
private java.lang.String
chooseVisitors
private java.util.List<FindBugsTask.ClassLocation>
classLocations
private boolean
conserveSpace
private java.util.List<org.apache.tools.ant.types.DirSet>
dirsets
private java.lang.String
effort
private java.io.File
excludeFile
private org.apache.tools.ant.types.Path
excludePath
private java.util.List<org.apache.tools.ant.types.FileSet>
filesets
private java.io.File
includeFile
private org.apache.tools.ant.types.Path
includePath
private int
maxRank
private boolean
nested
private boolean
noClassOk
private java.lang.String
omitVisitors
private java.lang.String
onlyAnalyze
private java.lang.String
outputFileName
private java.lang.String
outputFormat
private java.io.File
projectFile
private java.lang.String
projectName
private boolean
quietErrors
private boolean
relaxed
private java.lang.String
reportLevel
private boolean
setExitCode
private boolean
sorted
private org.apache.tools.ant.types.Path
sourcePath
private java.lang.String
stylesheet
private boolean
timestampNow
private java.io.File
userPreferencesFile
private java.lang.String
visitors
private java.lang.String
warningsProperty
private boolean
workHard
-
Fields inherited from class edu.umd.cs.findbugs.anttask.AbstractFindBugsTask
DEFAULT_TIMEOUT, errorProperty, execResultProperty, FINDBUGS_JAR, RESULT_PROPERTY_SUFFIX
-
-
Constructor Summary
Constructors Constructor Description FindBugsTask()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDirset(org.apache.tools.ant.types.DirSet fs)
Add a nested dirset of classes dirs.void
addFileset(org.apache.tools.ant.types.FileSet fs)
Add a nested fileset of classes or jar files.protected void
afterExecuteJavaProcess(int rc)
protected void
beforeExecuteJavaProcess()
protected void
checkParameters()
Check that all required attributes have been setprotected void
configureFindbugsEngine()
org.apache.tools.ant.types.Path
createAuxAnalyzepath()
Path to use for auxAnalyzepath.org.apache.tools.ant.types.Path
createAuxClasspath()
Path to use for auxclasspath.FindBugsTask.ClassLocation
createClass()
Add a class locationorg.apache.tools.ant.types.Path
createExcludePath()
Path to use for excludepath.org.apache.tools.ant.types.Path
createIncludePath()
Path to use for includepath.org.apache.tools.ant.types.Path
createSourcePath()
Path to use for sourcepath.void
setAdjustExperimental(boolean adjustExperimental)
Set the adjustExperimental flagvoid
setAdjustPriority(java.lang.String adjustPriorityString)
void
setApplySuppression(boolean flag)
Set the applySuppression flagvoid
setAuxAnalyzepath(org.apache.tools.ant.types.Path src)
the auxAnalyzepath to use.void
setAuxAnalyzepathRef(org.apache.tools.ant.types.Reference r)
Adds a reference to a auxAnalyzepath defined elsewhere.void
setAuxClasspath(org.apache.tools.ant.types.Path src)
the auxclasspath to use.void
setAuxClasspathRef(org.apache.tools.ant.types.Reference r)
Adds a reference to a sourcepath defined elsewhere.void
setBaselineBugs(java.io.File baselineBugs)
Set the baseline bugs filevoid
setChooseVisitors(java.lang.String commaSeperatedString)
Set the specific visitors to usevoid
setConserveSpace(boolean flag)
Set the conserveSpace flag.void
setEffort(java.lang.String effort)
Set effort level.void
setExcludeFilter(java.io.File filterFile)
Set the exclude filter filevoid
setExcludePath(org.apache.tools.ant.types.Path src)
the excludepath to use.void
setExcludePathRef(org.apache.tools.ant.types.Reference r)
Adds a reference to a source path defined elsewhere.void
setIncludeFilter(java.io.File filterFile)
Set the include filter filevoid
setIncludePath(org.apache.tools.ant.types.Path src)
the includepath to use.void
setIncludePathRef(org.apache.tools.ant.types.Reference r)
Adds a reference to a include path defined elsewhere.void
setMaxRank(int maxRank)
void
setNested(boolean nested)
Set the nested flag.void
setNoClassOk(boolean noClassOk)
Set the noClassOk flag.void
setOmitVisitors(java.lang.String commaSeperatedString)
Set the specific visitors to usevoid
setOnlyAnalyze(java.lang.String filter)
Set the packages or classes to analyzevoid
setOutput(java.lang.String format)
Set the output formatvoid
setOutputFile(java.lang.String outputFileName)
Set name of output file.void
setProjectFile(java.io.File projectFile)
Set the project filevoid
setProjectName(java.lang.String projectName)
Set project namevoid
setQuietErrors(boolean flag)
Set the quietErrors flagvoid
setRelaxed(boolean relaxed)
Set the relaxed flag.void
setReportLevel(java.lang.String level)
Set the report levelvoid
setSetExitCode(boolean setExitCode)
Set the exit code flag.void
setSort(boolean flag)
Set the sorted flagvoid
setSourcePath(org.apache.tools.ant.types.Path src)
the sourcepath to use.void
setSourcePathRef(org.apache.tools.ant.types.Reference r)
Adds a reference to a source path defined elsewhere.void
setStylesheet(java.lang.String stylesheet)
Set the stylesheet filename for HTML generation.void
setTimestampNow(boolean flag)
Set the timestampNow flagvoid
setUserPreferencesFile(java.io.File userPreferencesFile)
Set the user preferences filevoid
setVisitors(java.lang.String commaSeperatedString)
Set the specific visitors to usevoid
setWarningsProperty(java.lang.String name)
Tells this task to set the property with the given name to "true" when bugs were found.void
setWorkHard(boolean workHard)
Set the workHard flag.-
Methods inherited from class edu.umd.cs.findbugs.anttask.AbstractFindBugsTask
addArg, createClasspath, createFindbugsEngine, createPluginList, createSystemProperty, execute, getDebug, getFindbugsEngine, setClasspath, setClasspathRef, setDebug, setErrorProperty, setFailOnError, setHome, setInputString, setJvm, setJvmargs, setPluginList, setPluginListRef, setTimeout
-
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
-
-
-
-
Field Detail
-
effort
private java.lang.String effort
-
conserveSpace
private boolean conserveSpace
-
sorted
private boolean sorted
-
timestampNow
private boolean timestampNow
-
quietErrors
private boolean quietErrors
-
warningsProperty
private java.lang.String warningsProperty
-
maxRank
private int maxRank
-
projectName
private java.lang.String projectName
-
workHard
private boolean workHard
-
relaxed
private boolean relaxed
-
adjustExperimental
private boolean adjustExperimental
-
adjustPriority
private java.lang.String adjustPriority
-
projectFile
private java.io.File projectFile
-
userPreferencesFile
private java.io.File userPreferencesFile
-
baselineBugs
private java.io.File baselineBugs
-
applySuppression
private boolean applySuppression
-
excludeFile
private java.io.File excludeFile
-
excludePath
private org.apache.tools.ant.types.Path excludePath
-
includeFile
private java.io.File includeFile
-
includePath
private org.apache.tools.ant.types.Path includePath
-
auxClasspath
private org.apache.tools.ant.types.Path auxClasspath
-
auxAnalyzepath
private org.apache.tools.ant.types.Path auxAnalyzepath
-
sourcePath
private org.apache.tools.ant.types.Path sourcePath
-
outputFormat
private java.lang.String outputFormat
-
reportLevel
private java.lang.String reportLevel
-
visitors
private java.lang.String visitors
-
chooseVisitors
private java.lang.String chooseVisitors
-
omitVisitors
private java.lang.String omitVisitors
-
outputFileName
private java.lang.String outputFileName
-
stylesheet
private java.lang.String stylesheet
-
classLocations
private final java.util.List<FindBugsTask.ClassLocation> classLocations
-
onlyAnalyze
private java.lang.String onlyAnalyze
-
noClassOk
private boolean noClassOk
-
nested
private boolean nested
-
setExitCode
private boolean setExitCode
-
filesets
private final java.util.List<org.apache.tools.ant.types.FileSet> filesets
-
dirsets
private final java.util.List<org.apache.tools.ant.types.DirSet> dirsets
-
-
Method Detail
-
setWorkHard
public void setWorkHard(boolean workHard)
Set the workHard flag.- Parameters:
workHard
- true if we want findbugs to run with workHard option enabled
-
setSetExitCode
public void setSetExitCode(boolean setExitCode)
Set the exit code flag.- Parameters:
setExitCode
- If true then the exit code will be returned to the main ant job
-
setNested
public void setNested(boolean nested)
Set the nested flag.- Parameters:
nested
- This option enables or disables scanning of nested jar and zip files found in the list of files and directories to be analyzed. By default, scanning of nested jar/zip files is enabled
-
setNoClassOk
public void setNoClassOk(boolean noClassOk)
Set the noClassOk flag.- Parameters:
noClassOk
- true if we should generate no-error output if no classfiles are specified
-
setRelaxed
public void setRelaxed(boolean relaxed)
Set the relaxed flag.- Parameters:
relaxed
- true if we want findbugs to run with relaxed option enabled
-
setAdjustExperimental
public void setAdjustExperimental(boolean adjustExperimental)
Set the adjustExperimental flag- Parameters:
adjustExperimental
- true if we want experimental bug patterns to have lower priority
-
setAdjustPriority
public void setAdjustPriority(java.lang.String adjustPriorityString)
-
setVisitors
public void setVisitors(java.lang.String commaSeperatedString)
Set the specific visitors to use- Parameters:
commaSeperatedString
- visitors to use
-
setChooseVisitors
public void setChooseVisitors(java.lang.String commaSeperatedString)
Set the specific visitors to use- Parameters:
commaSeperatedString
- visitors to use
-
setOmitVisitors
public void setOmitVisitors(java.lang.String commaSeperatedString)
Set the specific visitors to use- Parameters:
commaSeperatedString
- visitors to use
-
setOutput
public void setOutput(java.lang.String format)
Set the output format- Parameters:
format
- output format
-
setStylesheet
public void setStylesheet(java.lang.String stylesheet)
Set the stylesheet filename for HTML generation.- Parameters:
stylesheet
- stylesheet filename for HTML generation
-
setReportLevel
public void setReportLevel(java.lang.String level)
Set the report level- Parameters:
level
- the report level
-
setSort
public void setSort(boolean flag)
Set the sorted flag- Parameters:
flag
- sorted
-
setTimestampNow
public void setTimestampNow(boolean flag)
Set the timestampNow flag- Parameters:
flag
- timestampNow
-
setQuietErrors
public void setQuietErrors(boolean flag)
Set the quietErrors flag- Parameters:
flag
- quietErrors
-
setApplySuppression
public void setApplySuppression(boolean flag)
Set the applySuppression flag- Parameters:
flag
- applySuppression
-
setWarningsProperty
public void setWarningsProperty(java.lang.String name)
Tells this task to set the property with the given name to "true" when bugs were found.- Parameters:
name
- property with the given name
-
setEffort
public void setEffort(java.lang.String effort)
Set effort level.- Parameters:
effort
- the effort level
-
setMaxRank
public void setMaxRank(int maxRank)
-
setProjectName
public void setProjectName(java.lang.String projectName)
Set project name- Parameters:
projectName
- the project name
-
setConserveSpace
public void setConserveSpace(boolean flag)
Set the conserveSpace flag.- Parameters:
flag
- conserveSpace
-
setExcludeFilter
public void setExcludeFilter(java.io.File filterFile)
Set the exclude filter file- Parameters:
filterFile
- exclude filter file
-
setIncludeFilter
public void setIncludeFilter(java.io.File filterFile)
Set the include filter file- Parameters:
filterFile
- include filter file
-
setBaselineBugs
public void setBaselineBugs(java.io.File baselineBugs)
Set the baseline bugs file- Parameters:
baselineBugs
- baseline bugs file
-
setProjectFile
public void setProjectFile(java.io.File projectFile)
Set the project file- Parameters:
projectFile
- project file
-
setUserPreferencesFile
public void setUserPreferencesFile(java.io.File userPreferencesFile)
Set the user preferences file- Parameters:
userPreferencesFile
- user preferences file
-
setAuxClasspath
public void setAuxClasspath(org.apache.tools.ant.types.Path src)
the auxclasspath to use.- Parameters:
src
- auxclasspath to use
-
createAuxClasspath
public org.apache.tools.ant.types.Path createAuxClasspath()
Path to use for auxclasspath.- Returns:
- auxclasspath
-
setAuxClasspathRef
public void setAuxClasspathRef(org.apache.tools.ant.types.Reference r)
Adds a reference to a sourcepath defined elsewhere.- Parameters:
r
- reference to a sourcepath defined elsewhere
-
setAuxAnalyzepath
public void setAuxAnalyzepath(org.apache.tools.ant.types.Path src)
the auxAnalyzepath to use.- Parameters:
src
- auxAnalyzepath
-
createAuxAnalyzepath
public org.apache.tools.ant.types.Path createAuxAnalyzepath()
Path to use for auxAnalyzepath.- Returns:
- auxAnalyzepath
-
setAuxAnalyzepathRef
public void setAuxAnalyzepathRef(org.apache.tools.ant.types.Reference r)
Adds a reference to a auxAnalyzepath defined elsewhere.- Parameters:
r
- reference to a auxAnalyzepath defined elsewhe
-
setSourcePath
public void setSourcePath(org.apache.tools.ant.types.Path src)
the sourcepath to use.- Parameters:
src
- sourcepath
-
createSourcePath
public org.apache.tools.ant.types.Path createSourcePath()
Path to use for sourcepath.- Returns:
- sourcepath
-
setSourcePathRef
public void setSourcePathRef(org.apache.tools.ant.types.Reference r)
Adds a reference to a source path defined elsewhere.- Parameters:
r
- reference to a source path defined elsewhere
-
setExcludePath
public void setExcludePath(org.apache.tools.ant.types.Path src)
the excludepath to use.- Parameters:
src
- excludepath
-
createExcludePath
public org.apache.tools.ant.types.Path createExcludePath()
Path to use for excludepath.- Returns:
- excludepath
-
setExcludePathRef
public void setExcludePathRef(org.apache.tools.ant.types.Reference r)
Adds a reference to a source path defined elsewhere.- Parameters:
r
- reference to a exclude path defined elsewhe
-
setIncludePath
public void setIncludePath(org.apache.tools.ant.types.Path src)
the includepath to use.- Parameters:
src
- includepath
-
createIncludePath
public org.apache.tools.ant.types.Path createIncludePath()
Path to use for includepath.- Returns:
- includepath
-
setIncludePathRef
public void setIncludePathRef(org.apache.tools.ant.types.Reference r)
Adds a reference to a include path defined elsewhere.- Parameters:
r
- reference to a include path defined elsewher
-
createClass
public FindBugsTask.ClassLocation createClass()
Add a class location- Returns:
- class location
-
setOutputFile
public void setOutputFile(java.lang.String outputFileName)
Set name of output file.- Parameters:
outputFileName
- name of output file
-
setOnlyAnalyze
public void setOnlyAnalyze(java.lang.String filter)
Set the packages or classes to analyze- Parameters:
filter
- packages or classes to analyze
-
addFileset
public void addFileset(org.apache.tools.ant.types.FileSet fs)
Add a nested fileset of classes or jar files.- Parameters:
fs
- nested fileset of classes or jar files
-
addDirset
public void addDirset(org.apache.tools.ant.types.DirSet fs)
Add a nested dirset of classes dirs.- Parameters:
fs
- nested dirset of classes dirs
-
checkParameters
protected void checkParameters()
Check that all required attributes have been set- Overrides:
checkParameters
in classAbstractFindBugsTask
-
beforeExecuteJavaProcess
protected void beforeExecuteJavaProcess()
- Specified by:
beforeExecuteJavaProcess
in classAbstractFindBugsTask
-
afterExecuteJavaProcess
protected void afterExecuteJavaProcess(int rc)
- Overrides:
afterExecuteJavaProcess
in classAbstractFindBugsTask
-
configureFindbugsEngine
protected void configureFindbugsEngine()
- Specified by:
configureFindbugsEngine
in classAbstractFindBugsTask
-
-