Package 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.AbstractCodeQualityTask
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`, `Named`, `ExtensionAware`, `Reporting<PmdReports>`, `Task`, `PatternFilterable`, `VerificationTask`, `Configurable<Task>`

@CacheableTask public abstract class Pmd extends AbstractCodeQualityTask implements 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.Named

  `Named.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
  `Pmd()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `@Nullable FileCollection`
  `getClasspath()`
  Compile class path for the classes to be analyzed.
  `abstract Property<Boolean>`
  `getIncrementalAnalysis()`
  Controls whether to use incremental analysis or not.
  `File`
  `getIncrementalCacheFile()`
  Path to the incremental cache file, if incremental analysis is used.
  `abstract Property<Integer>`
  `getMaxFailures()`
  The maximum number of failures to allow before stopping the build.
  `FileCollection`
  `getPmdClasspath()`
  The class path containing the PMD library to be used.
  `final PmdReports`
  `getReports()`
  The reports to be generated by this task.
  `@Nullable 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.
  `abstract Property<Integer>`
  `getRulesMinimumPriority()`
  Specifies the rule priority threshold.
  `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.
  `abstract Property<Integer>`
  `getThreads()`
  Specifies the number of threads used by PMD.
  `boolean`
  `isConsoleOutput()`
  Whether or not to write PMD results to `System.out`.
  `PmdReports`
  `reports(Closure closure)`
  Configures the reports to be generated by this task.
  `PmdReports`
  `reports(Action<? super PmdReports> configureAction)`
  Configures the reports to be generated by this task.
  `void`
  `run()`
  `void`
  `setClasspath(@Nullable FileCollection classpath)`
  Compile class path for the classes to be analyzed.
  `void`
  `setConsoleOutput(boolean consoleOutput)`
  Whether or not to write PMD results to `System.out`.
  `void`
  `setPmdClasspath(FileCollection pmdClasspath)`
  The class path containing the PMD library to be used.
  `void`
  `setRuleSetConfig(@Nullable TextResource ruleSetConfig)`
  The custom rule set to be used (if any).
  `void`
  `setRuleSetFiles(FileCollection ruleSetFiles)`
  The custom rule set files to be used.
  `void`
  `setRuleSets(List<String> ruleSets)`
  The built-in rule sets to be used.
  `void`
  `setTargetJdk(TargetJdk targetJdk)`
  The target JDK to use with PMD.
  `boolean`
  `stdOutIsAttachedToTerminal()`
  `static void`
  `validate(int value)`
  Validates the value is a valid PMD rules minimum priority (1-5)

  ### Methods inherited from class org.gradle.api.plugins.quality.AbstractCodeQualityTask

  `configureForkOptions, getIgnoreFailures, getIgnoreFailuresProperty, getJavaLauncher, getMaxHeapSize, getMinHeapSize, getObjectFactory, getToolchainService, getWorkerExecutor, setIgnoreFailures`

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

  `acceptServiceReferences, appendParallelSafeAction, doNotTrackState, doNotTrackStateIf, getAsDynamicObject, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonsNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, restoreOnlyIf, restoreTaskActions, 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, notCompatibleWithConfigurationCache`

- ## Constructor Details

  - ### Pmd

    public Pmd()

- ## Method Details

  - ### 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 rules minimum priority (1-5)
    Parameters:
      `value` - rules minimum priority threshold

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

    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)
    The class path containing the PMD library to be used.

  - ### getRuleSets

    @Input public List<String> getRuleSets()
    The built-in rule sets to be used. See the official list of built-in rule sets.

             ruleSets = ["basic", "braces"]

  - ### setRuleSets

    public void setRuleSets(List<String> ruleSets)
    The built-in rule sets to be used. See the official list of built-in rule sets.

             ruleSets = ["basic", "braces"]

  - ### getTargetJdk

    @Input public TargetJdk getTargetJdk()
    The target JDK to use with PMD.

  - ### setTargetJdk

    public void setTargetJdk(TargetJdk targetJdk)
    The target JDK to use with PMD.

  - ### getRuleSetConfig

    @Optional public @Nullable 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.

             ruleSetConfig = resources.text.fromFile(resources.file("config/pmd/myRuleSets.xml"))

    Since:
      2.2

  - ### setRuleSetConfig

    public void setRuleSetConfig(@Nullable TextResource ruleSetConfig)
    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.

             ruleSetConfig = resources.text.fromFile(resources.file("config/pmd/myRuleSets.xml"))

    Since:
      2.2

  - ### getRuleSetFiles

    @InputFiles @PathSensitive(NONE) public FileCollection getRuleSetFiles()
    The custom rule set files to be used. See the official documentation for how to author a rule set file. If you want to only use custom rule sets, you must clear `ruleSets`.

             ruleSetFiles = files("config/pmd/myRuleSet.xml")

  - ### setRuleSetFiles

    public void setRuleSetFiles(FileCollection ruleSetFiles)
    The custom rule set files to be used. See the official documentation for how to author a rule set file. This adds to the default rule sets defined by `getRuleSets()`.

             ruleSetFiles = files("config/pmd/myRuleSets.xml")

  - ### getReports

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

  - ### getMaxFailures

    @Input public abstract Property<Integer> getMaxFailures()
    The maximum number of failures to allow before stopping the build. Defaults to 0, which will stop the build on any failure. Values 0 and above are valid. If

        ignoreFailures

    is set, this is ignored and the build will continue (infinite failures allowed).
    Since:
      6.4

  - ### getRulesMinimumPriority

    @Input public abstract Property<Integer> getRulesMinimumPriority()
    Specifies the rule priority threshold.
    Since:
      6.8
    See Also:
      - `PmdExtension.getRulesMinimumPriority()`

  - ### isConsoleOutput

    @Input public boolean isConsoleOutput()
    Whether or not to write PMD results to `System.out`.
    Since:
      2.1

  - ### setConsoleOutput

    public void setConsoleOutput(boolean consoleOutput)
    Whether or not to write PMD results to `System.out`.
    Since:
      2.1

  - ### getClasspath

    @Optional @Classpath public @Nullable 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.
    Since:
      2.8

  - ### setClasspath

    public void setClasspath(@Nullable FileCollection classpath)
    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.
    Since:
      2.8

  - ### getIncrementalAnalysis

    @Internal public abstract Property<Boolean> getIncrementalAnalysis()
    Controls whether to use incremental analysis or not. This is only supported for PMD 6.0.0 or better. See for more details.
    Since:
      5.6

  - ### getIncrementalCacheFile

    @LocalState public File getIncrementalCacheFile()
    Path to the incremental cache file, if incremental analysis is used.
    Since:
      5.6

  - ### getThreads

    @Input public abstract Property<Integer> getThreads()
    Specifies the number of threads used by PMD.
    Since:
      7.5
    See Also:
      - `PmdExtension.getThreads()`