Package org.gradle.api.plugins.quality
Class Checkstyle
java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
org.gradle.api.internal.ConventionTask
org.gradle.api.tasks.SourceTask
org.gradle.api.plugins.quality.Checkstyle
- All Implemented Interfaces:
Comparable<Task>
,org.gradle.api.internal.DynamicObjectAware
,org.gradle.api.internal.IConventionAware
,org.gradle.api.internal.TaskInternal
,ExtensionAware
,Reporting<CheckstyleReports>
,Task
,PatternFilterable
,VerificationTask
,org.gradle.util.Configurable<Task>
@CacheableTask
public class Checkstyle
extends SourceTask
implements VerificationTask, Reporting<CheckstyleReports>
Runs Checkstyle against some source files.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.gradle.api.Task
Task.Namer
-
Field Summary
Fields inherited from class org.gradle.api.tasks.SourceTask
source
Fields inherited from interface org.gradle.api.Task
TASK_ACTION, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.gradle.api.internal.project.IsolatedAntBuilder
The class path containing the Checkstyle library to be used.The class path containing the compiled classes for the source files to be analyzed.The Checkstyle configuration to use.Path to other Checkstyle configuration files.The Checkstyle configuration file to use.The properties available for use in the configuration file.boolean
Whether or not this task will ignore failures and continue running the build.int
The maximum number of errors that are tolerated before breaking the build or setting the failure property.int
The maximum number of warnings that are tolerated before breaking the build or setting the failure property.Injects and returns an instance ofObjectFactory
.final CheckstyleReports
The reports to be generated by this task.Returns the source for this task, after the include and exclude patterns have been applied.boolean
Whether this task will ignore failures and continue running the build.boolean
Whether rule violations are to be displayed on the console.Configures the reports to be generated by this task.reports
(Action<? super CheckstyleReports> configureAction) Configures the reports to be generated by this task.void
run()
void
setCheckstyleClasspath
(FileCollection checkstyleClasspath) The class path containing the Checkstyle library to be used.void
setClasspath
(FileCollection classpath) The class path containing the compiled classes for the source files to be analyzed.void
setConfig
(TextResource config) The Checkstyle configuration to use.void
setConfigDir
(Provider<File> configDir) Path to other Checkstyle configuration files.void
setConfigFile
(File configFile) The Checkstyle configuration file to use.void
setConfigProperties
(Map<String, Object> configProperties) The properties available for use in the configuration file.void
setIgnoreFailures
(boolean ignoreFailures) Whether this task will ignore failures and continue running the build.void
setMaxErrors
(int maxErrors) Set the maximum number of errors that are tolerated before breaking the build.void
setMaxWarnings
(int maxWarnings) Set the maximum number of warnings that are tolerated before breaking the build.void
setShowViolations
(boolean showViolations) Whether rule violations are to be displayed on the console.Methods inherited from class org.gradle.api.tasks.SourceTask
exclude, exclude, exclude, exclude, getExcludes, getIncludes, getPatternSetFactory, include, include, include, include, setExcludes, setIncludes, setSource, setSource, source
Methods inherited from class org.gradle.api.internal.ConventionTask
conventionMapping, conventionMapping, getConventionMapping
Methods inherited from class org.gradle.api.DefaultTask
newInputDirectory, newInputFile, newOutputDirectory, newOutputFile
Methods inherited from class org.gradle.api.internal.AbstractTask
addValidator, appendParallelSafeAction, compareTo, configure, deleteAllActions, dependsOn, dependsOnTaskDidWork, doFirst, doFirst, doFirst, doLast, doLast, doLast, execute, finalizedBy, getActions, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExecuter, getExtensions, getFinalizedBy, getGroup, getIdentityPath, getImpliesSubProjects, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOnlyIf, getOutputs, getPath, getProject, getServices, getShouldRunAfter, getStandardOutputCapture, getState, getTaskActions, getTaskDependencies, getTemporaryDir, getTemporaryDirFactory, getValidators, hasProperty, injectIntoNewInstance, isEnabled, isHasCustomActions, leftShift, mustRunAfter, onlyIf, onlyIf, prependParallelSafeAction, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setExecuter, setFinalizedBy, setGroup, setImpliesSubProjects, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, toString
-
Constructor Details
-
Checkstyle
public Checkstyle()
-
-
Method Details
-
getConfigFile
The Checkstyle configuration file to use. -
setConfigFile
The Checkstyle configuration file to use. -
getObjectFactory
Injects and returns an instance ofObjectFactory
.- Since:
- 4.2
-
getAntBuilder
@Inject public org.gradle.api.internal.project.IsolatedAntBuilder getAntBuilder() -
reports
public CheckstyleReports reports(@DelegatesTo(value=CheckstyleReports.class,strategy=1) Closure closure) Configures the reports to be generated by this task. The contained reports can be configured by name and closures. Example:checkstyleTask { reports { html { destination "build/codenarc.html" } } }
- Specified by:
reports
in interfaceReporting<CheckstyleReports>
- Parameters:
closure
- The configuration- Returns:
- The reports container
-
reports
Configures the reports to be generated by this task. The contained reports can be configured by name and closures. Example:checkstyleTask { reports { html { destination "build/codenarc.html" } } }
- Specified by:
reports
in interfaceReporting<CheckstyleReports>
- Parameters:
configureAction
- The configuration- Returns:
- The reports container
- Since:
- 3.0
-
run
public void run() -
getSource
Returns the source for this task, after the include and exclude patterns have been applied. Ignores source files which do not exist.The sources for this task are relatively relocatable even though it produces output that includes absolute paths. This is a compromise made to ensure that results can be reused between different builds. The downside is that up-to-date results, or results loaded from cache can show different absolute paths than would be produced if the task was executed.
- Overrides:
getSource
in classSourceTask
- Returns:
- The source.
-
getCheckstyleClasspath
The class path containing the Checkstyle library to be used. -
setCheckstyleClasspath
The class path containing the Checkstyle library to be used. -
getClasspath
The class path containing the compiled classes for the source files to be analyzed. -
setClasspath
The class path containing the compiled classes for the source files to be analyzed. -
getConfig
The Checkstyle configuration to use. Replaces theconfigFile
property.- Since:
- 2.2
-
setConfig
The Checkstyle configuration to use. Replaces theconfigFile
property.- Since:
- 2.2
-
getConfigProperties
The properties available for use in the configuration file. These are substituted into the configuration file. -
setConfigProperties
The properties available for use in the configuration file. These are substituted into the configuration file. -
getConfigDir
Path to other Checkstyle configuration files.This path will be exposed as the variable
config_loc
in Checkstyle's configuration files.- Returns:
- path to other Checkstyle configuration files
- Since:
- 4.0
-
setConfigDir
Path to other Checkstyle configuration files.This path will be exposed as the variable
config_loc
in Checkstyle's configuration files.- Since:
- 4.0
-
getReports
The reports to be generated by this task.- Specified by:
getReports
in interfaceReporting<CheckstyleReports>
- Returns:
- The report container
-
getIgnoreFailures
public boolean getIgnoreFailures()Whether or not this task will ignore failures and continue running the build.- Specified by:
getIgnoreFailures
in interfaceVerificationTask
- Returns:
- true if failures should be ignored
-
isIgnoreFailures
public boolean isIgnoreFailures()Whether this task will ignore failures and continue running the build.- Returns:
- true if failures should be ignored
-
setIgnoreFailures
public void setIgnoreFailures(boolean ignoreFailures) Whether this task will ignore failures and continue running the build.- Specified by:
setIgnoreFailures
in interfaceVerificationTask
- Parameters:
ignoreFailures
- false to break the build on failure, true to ignore the failures. The default is false.
-
getMaxErrors
The maximum number of errors that are tolerated before breaking the build or setting the failure property.- Returns:
- the maximum number of errors allowed
- Since:
- 3.4
-
setMaxErrors
public void setMaxErrors(int maxErrors) Set the maximum number of errors that are tolerated before breaking the build.- Parameters:
maxErrors
- number of errors allowed- Since:
- 3.4
-
getMaxWarnings
The maximum number of warnings that are tolerated before breaking the build or setting the failure property.- Returns:
- the maximum number of warnings allowed
- Since:
- 3.4
-
setMaxWarnings
public void setMaxWarnings(int maxWarnings) Set the maximum number of warnings that are tolerated before breaking the build.- Parameters:
maxWarnings
- number of warnings allowed- Since:
- 3.4
-
isShowViolations
Whether rule violations are to be displayed on the console.- Returns:
- true if violations should be displayed on console
-
setShowViolations
public void setShowViolations(boolean showViolations) Whether rule violations are to be displayed on the console.
-