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:
    `java.lang.Comparable<Task>`, `org.gradle.api.internal.DynamicObjectAware`, `org.gradle.api.internal.IConventionAware`, `org.gradle.api.internal.TaskInternal`, `ExtensionAware`, `Reporting<CheckstyleReports>`, `Task`, `PatternFilterable`, `VerificationTask`, `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 interface org.gradle.api.Task

      `TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Checkstyle()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `org.gradle.api.internal.project.IsolatedAntBuilder` | `getAntBuilder()` | Deprecated.
    `FileCollection` | `getCheckstyleClasspath()` | The class path containing the Checkstyle library to be used.
    `FileCollection` | `getClasspath()` | The class path containing the compiled classes for the source files to be analyzed.
    `TextResource` | `getConfig()` | The Checkstyle configuration to use.
    `DirectoryProperty` | `getConfigDirectory()` | Path to other Checkstyle configuration files.
    `java.io.File` | `getConfigFile()` | The Checkstyle configuration file to use.
    `java.util.Map<java.lang.String,​java.lang.Object>` | `getConfigProperties()` | The properties available for use in the configuration file.
    `Property<java.lang.Boolean>` | `getEnableExternalDtdLoad()` | Enable the use of external DTD files in configuration files.
    `boolean` | `getIgnoreFailures()` | Whether or not this task will ignore failures and continue running the build.
    `Property<JavaLauncher>` | `getJavaLauncher()` | JavaLauncher for toolchain support.
    `int` | `getMaxErrors()` | The maximum number of errors that are tolerated before breaking the build or setting the failure property.
    `Property<java.lang.String>` | `getMaxHeapSize()` | The maximum heap size for the Checkstyle worker process, if any.
    `int` | `getMaxWarnings()` | The maximum number of warnings that are tolerated before breaking the build or setting the failure property.
    `Property<java.lang.String>` | `getMinHeapSize()` | The minimum heap size for the Checkstyle worker process, if any.
    `protected ObjectFactory` | `getObjectFactory()` |
    `CheckstyleReports` | `getReports()` | The reports to be generated by this task.
    `FileTree` | `getSource()` | Returns the source for this task, after the include and exclude patterns have been applied.
    `protected JavaToolchainService` | `getToolchainService()` |
    `WorkerExecutor` | `getWorkerExecutor()` |
    `boolean` | `isIgnoreFailures()` | Whether this task will ignore failures and continue running the build.
    `boolean` | `isShowViolations()` | Whether rule violations are to be displayed on the console.
    `CheckstyleReports` | `reports​(Closure closure)` | Configures the reports to be generated by this task.
    `CheckstyleReports` | `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` | `setConfigFile​(java.io.File configFile)` | The Checkstyle configuration file to use.
    `void` | `setConfigProperties​(java.util.Map<java.lang.String,​java.lang.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, getPatternSet, 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

      `compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService`

    - ### Methods inherited from class org.gradle.api.internal.AbstractTask

      `appendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjects`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.gradle.api.Task

      `doNotTrackState, getConvention, notCompatibleWithConfigurationCache`

- - ### Constructor Detail

    - #### Checkstyle

          public Checkstyle()

  - ### Method Detail

    - #### getConfigFile

          @Internal
          public java.io.File getConfigFile()

      The Checkstyle configuration file to use.

    - #### setConfigFile

          public void setConfigFile​(java.io.File configFile)

      The Checkstyle configuration file to use.

    - #### getObjectFactory

          @Inject
          protected ObjectFactory getObjectFactory()

    - #### getToolchainService

          @Inject
          protected JavaToolchainService getToolchainService()

    - #### getAntBuilder

          @Inject
          @Deprecated
          public org.gradle.api.internal.project.IsolatedAntBuilder getAntBuilder()

      Deprecated.

    - #### getWorkerExecutor

          @Inject
          public WorkerExecutor getWorkerExecutor()

    - #### 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/checkstyle.html"
               }
             }
           }

      Specified by:
        `reports` in interface `Reporting<CheckstyleReports>`
      Parameters:
        `closure` - The configuration
      Returns:
        The reports container

    - #### reports

          public CheckstyleReports reports​(Action<? super CheckstyleReports> configureAction)

      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/checkstyle.html"
               }
             }
           }

      Specified by:
        `reports` in interface `Reporting<CheckstyleReports>`
      Parameters:
        `configureAction` - The configuration
      Returns:
        The reports container
      Since:
        3.0

    - #### getJavaLauncher

          @Incubating
          public Property<JavaLauncher> getJavaLauncher()

      JavaLauncher for toolchain support.
      Since:
        7.5

    - #### run

          public void run()

    - #### getSource

          @PathSensitive(RELATIVE)
          public FileTree getSource()

      Returns the source for this task, after the include and exclude patterns have been applied. Ignores source files which do not exist.

      The `PathSensitivity` for the sources is configured to be `PathSensitivity.ABSOLUTE`. If your sources are less strict, please change it accordingly by overriding this method in your subclass.

      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 class `SourceTask`
      Returns:
        The source.

    - #### getCheckstyleClasspath

          @Classpath
          public FileCollection getCheckstyleClasspath()

      The class path containing the Checkstyle library to be used.

    - #### setCheckstyleClasspath

          public void setCheckstyleClasspath​(FileCollection checkstyleClasspath)

      The class path containing the Checkstyle library to be used.

    - #### getClasspath

          @Classpath
          public FileCollection getClasspath()

      The class path containing the compiled classes for the source files to be analyzed.

    - #### setClasspath

          public void setClasspath​(FileCollection classpath)

      The class path containing the compiled classes for the source files to be analyzed.

    - #### getConfig

          public TextResource getConfig()

      The Checkstyle configuration to use. Replaces the `configFile` property.
      Since:
        2.2

    - #### setConfig

          public void setConfig​(TextResource config)

      The Checkstyle configuration to use. Replaces the `configFile` property.
      Since:
        2.2

    - #### getConfigProperties

          @Nullable
          @Optional
          @Input
          public java.util.Map<java.lang.String,​java.lang.Object> getConfigProperties()

      The properties available for use in the configuration file. These are substituted into the configuration file.

    - #### setConfigProperties

          public void setConfigProperties​(@Nullable
                                          java.util.Map<java.lang.String,​java.lang.Object> configProperties)

      The properties available for use in the configuration file. These are substituted into the configuration file.

    - #### getConfigDirectory

          @PathSensitive(RELATIVE)
          @InputFiles
          public DirectoryProperty getConfigDirectory()

      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:
        6.0

    - #### getReports

          public final CheckstyleReports getReports()

      The reports to be generated by this task.
      Specified by:
        `getReports` in interface `Reporting<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 interface `VerificationTask`
      Returns:
        true if failures should be ignored

    - #### isIgnoreFailures

          @Internal
          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 interface `VerificationTask`
      Parameters:
        `ignoreFailures` - false to break the build on failure, true to ignore the failures. The default is false.

    - #### getMaxErrors

          @Input
          public int 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

          @Input
          public int 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

          @Console
          public boolean 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.

    - #### getMinHeapSize

          @Incubating
          @Optional
          @Input
          public Property<java.lang.String> getMinHeapSize()

      The minimum heap size for the Checkstyle worker process, if any. Supports the units megabytes (e.g. "512m") and gigabytes (e.g. "1g").
      Returns:
        The minimum heap size. Value should be null if the default minimum heap size should be used.
      Since:
        7.5

    - #### getMaxHeapSize

          @Incubating
          @Optional
          @Input
          public Property<java.lang.String> getMaxHeapSize()

      The maximum heap size for the Checkstyle worker process, if any. Supports the units megabytes (e.g. "512m") and gigabytes (e.g. "1g").
      Returns:
        The maximum heap size. Value should be null if the default maximum heap size should be used.
      Since:
        7.5

    - #### getEnableExternalDtdLoad

          @Incubating
          @Input
          public Property<java.lang.Boolean> getEnableExternalDtdLoad()

      Enable the use of external DTD files in configuration files. Disabled by default because this may be unsafe. See Checkstyle documentation for more details.
      Returns:
        property to enable the use of external DTD files
      Since:
        7.6