org.gradle.api.plugins.quality

## Class Pmd

- 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.Pmd

- All Implemented Interfaces:
    Comparable<Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.IConventionAware, org.gradle.api.internal.TaskInternal, ExtensionAware, Reporting<PmdReports>, Task, PatternFilterable, VerificationTask, org.gradle.util.Configurable<Task>

      @CacheableTask
      public class Pmd
      extends SourceTask
      implements VerificationTask, Reporting<PmdReports>

  Runs a set of static code analysis rules on Java source code files and generates a report of problems found.
  See Also:
    `PmdPlugin`, `PmdExtension`

- - ### 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

    Constructors
    Constructor and Description
    `Pmd()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `org.gradle.api.internal.project.IsolatedAntBuilder` | `getAntBuilder()`
    `FileCollection` | `getClasspath()` Compile class path for the classes to be analyzed.
    `boolean` | `getIgnoreFailures()` Whether or not to allow the build to continue if there are warnings.
    `org.gradle.internal.reflect.Instantiator` | `getInstantiator()`
    `FileCollection` | `getPmdClasspath()` The class path containing the PMD library to be used.
    `PmdReports` | `getReports()` The reports to be generated by this task.
    `int` | `getRulePriority()` Specifies the rule priority threshold.
    `TextResource` | `getRuleSetConfig()` The custom rule set to be used (if any).
    `FileCollection` | `getRuleSetFiles()` The custom rule set files to be used.
    `List<String>` | `getRuleSets()` The built-in rule sets to be used.
    `FileTree` | `getSource()` Returns the source for this task, after the include and exclude patterns have been applied.
    `TargetJdk` | `getTargetJdk()` The target JDK to use with PMD.
    `boolean` | `isConsoleOutput()` Whether or not to write PMD results to `System.out`.
    `PmdReports` | `reports(Action<? super PmdReports> configureAction)` Configures the reports to be generated by this task.
    `PmdReports` | `reports(Closure closure)` Configures the reports to be generated by this task.
    `void` | `run()`
    `void` | `setClasspath(FileCollection classpath)`
    `void` | `setConsoleOutput(boolean consoleOutput)`
    `void` | `setIgnoreFailures(boolean ignoreFailures)` Specifies whether the build should break when the verifications performed by this task fail.
    `void` | `setPmdClasspath(FileCollection pmdClasspath)`
    `void` | `setRulePriority(int intValue)` Sets the rule priority threshold.
    `void` | `setRuleSetConfig(TextResource ruleSetConfig)`
    `void` | `setRuleSetFiles(FileCollection ruleSetFiles)`
    `void` | `setRuleSets(List<String> ruleSets)`
    `void` | `setTargetJdk(TargetJdk targetJdk)`
    `boolean` | `stdOutIsAttachedToTerminal()`
    `static void` | `validate(int value)` Validates the value is a valid PMD RulePriority (1-5)

    - ### Methods inherited from class org.gradle.api.tasks.SourceTask

      `exclude, exclude, exclude, exclude, getExcludes, getIncludes, getPatternSetFactory, include, include, include, include, setExcludes, setIncludes, setSource, source`

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

      `conventionMapping, conventionMapping, getConventionMapping`

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

      `addValidator, appendParallelSafeAction, compareTo, configure, deleteAllActions, dependsOn, dependsOnTaskDidWork, doFirst, doFirst, doLast, doLast, execute, finalizedBy, getActionClassLoaders, getActions, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDidWork, getEnabled, getExecuter, getExtensions, getFinalizedBy, getGroup, getIdentityPath, getImpliesSubProjects, getInputs, 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`

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

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

- - ### Constructor Detail

    - #### Pmd

          public Pmd()

  - ### Method Detail

    - #### setRulePriority

          @Incubating
          public void setRulePriority(int intValue)

      Sets the rule priority threshold.

    - #### getInstantiator

          @Inject
          public org.gradle.internal.reflect.Instantiator getInstantiator()

    - #### getAntBuilder

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

    - #### run

          public void run()

    - #### stdOutIsAttachedToTerminal

          public boolean stdOutIsAttachedToTerminal()

    - #### reports

          public PmdReports reports(@DelegatesTo(value=PmdReports.class,strategy=1)
                           Closure closure)

      Configures the reports to be generated by this task.
      Specified by:
        `reports` in interface `Reporting<PmdReports>`
      Parameters:
        `closure` - The configuration
      Returns:
        The report container

    - #### reports

          public PmdReports reports(Action<? super PmdReports> configureAction)

      Configures the reports to be generated by this task.
      Specified by:
        `reports` in interface `Reporting<PmdReports>`
      Parameters:
        `configureAction` - The configuration
      Returns:
        The report container
      Since:
        3.0

    - #### validate

          public static void validate(int value)

      Validates the value is a valid PMD RulePriority (1-5)
      Parameters:
        `value` - rule priority threshold

    - #### getSource

          @PathSensitive(value=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.
      Overrides:
        `getSource` in class `SourceTask`
      Returns:
        The source.

    - #### getPmdClasspath

          @Classpath
          public FileCollection getPmdClasspath()

      The class path containing the PMD library to be used.

    - #### setPmdClasspath

          public void setPmdClasspath(FileCollection pmdClasspath)

    - #### getRuleSets

          @Input
          public List<String> getRuleSets()

      The built-in rule sets to be used. See the official list of built-in rule sets. Example: ruleSets = ["basic", "braces"]

    - #### setRuleSets

          public void setRuleSets(List<String> ruleSets)

    - #### getTargetJdk

          @Input
          public TargetJdk getTargetJdk()

      The target JDK to use with PMD.

    - #### setTargetJdk

          public void setTargetJdk(TargetJdk targetJdk)

    - #### getRuleSetConfig

          @Incubating
          @Optional
          public TextResource getRuleSetConfig()

      The custom rule set to be used (if any). Replaces `ruleSetFiles`, except that it does not currently support multiple rule sets. See the official documentation for how to author a rule set. Example: ruleSetConfig = resources.text.fromFile(resources.file("config/pmd/myRuleSets.xml"))
      Since:
        2.2

    - #### setRuleSetConfig

          public void setRuleSetConfig(TextResource ruleSetConfig)

    - #### getRuleSetFiles

          @InputFiles
          @PathSensitive(value=NONE)
          public FileCollection getRuleSetFiles()

      The custom rule set files to be used. See the official documentation for how to author a rule set file. Example: ruleSetFiles = files("config/pmd/myRuleSets.xml")

    - #### setRuleSetFiles

          public void setRuleSetFiles(FileCollection ruleSetFiles)

    - #### getReports

          public final PmdReports getReports()

      The reports to be generated by this task.
      Specified by:
        `getReports` in interface `Reporting<PmdReports>`
      Returns:
        The report container

    - #### getIgnoreFailures

          @Input
          public boolean getIgnoreFailures()

      Whether or not to allow the build to continue if there are warnings. Example: ignoreFailures = true
      Specified by:
        `getIgnoreFailures` in interface `VerificationTask`
      Returns:
        false, when the build should break on failure, true when the failures should be ignored.

    - #### setIgnoreFailures

          public void setIgnoreFailures(boolean ignoreFailures)

      Description copied from interface: `VerificationTask`
      Specifies whether the build should break when the verifications performed by this task fail.
      Specified by:
        `setIgnoreFailures` in interface `VerificationTask`
      Parameters:
        `ignoreFailures` - false to break the build on failure, true to ignore the failures. The default is false.

    - #### getRulePriority

          @Input
          @Incubating
          public int getRulePriority()

      Specifies the rule priority threshold.
      See Also:
        `PmdExtension.rulePriority`

    - #### isConsoleOutput

          @Input
          @Incubating
          public boolean isConsoleOutput()

      Whether or not to write PMD results to `System.out`.

    - #### setConsoleOutput

          public void setConsoleOutput(boolean consoleOutput)

    - #### getClasspath

          @Classpath
          @Optional
          @Incubating
          public FileCollection getClasspath()

      Compile class path for the classes to be analyzed. The classes on this class path are used during analysis but aren't analyzed themselves. This is only well supported for PMD 5.2.1 or better.

    - #### setClasspath

          public void setClasspath(FileCollection classpath)