api / org.gradle.api.plugins.quality / Pmd

Pmd

@CacheableTask open class Pmd : SourceTask, 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
PmdPluginPmdExtension

Constructors

<init>

Pmd()

Functions

getAntBuilder

open fun getAntBuilder(): IsolatedAntBuilder

getClasspath

open fun getClasspath(): FileCollection

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.

getIgnoreFailures

open fun getIgnoreFailures(): Boolean

Whether or not to allow the build to continue if there are warnings. Example: ignoreFailures = true

getObjectFactory

open fun getObjectFactory(): ObjectFactory

Injects and returns an instance of org.gradle.api.model.ObjectFactory.

getPmdClasspath

open fun getPmdClasspath(): FileCollection

The class path containing the PMD library to be used.

getReports

fun getReports(): PmdReports

The reports to be generated by this task.

getRulePriority

open fun getRulePriority(): Int

Specifies the rule priority threshold.

getRuleSetConfig

open fun getRuleSetConfig(): TextResource

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"))

getRuleSetFiles

open fun getRuleSetFiles(): FileCollection

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")

getRuleSets

open fun getRuleSets(): MutableList<String>

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

getSource

open fun getSource(): FileTree

{@inheritDoc}

getTargetJdk

open fun getTargetJdk(): TargetJdk

The target JDK to use with PMD.

isConsoleOutput

open fun isConsoleOutput(): Boolean

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

reports

open fun reports(closure: Closure<Any>): PmdReports
open fun reports(configureAction: Action<in PmdReports>): PmdReports

Configures the reports to be generated by this task.

run

open fun run(): Unit

setClasspath

open fun setClasspath(classpath: FileCollection): Unit

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.

setConsoleOutput

open fun setConsoleOutput(consoleOutput: Boolean): Unit

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

setIgnoreFailures

open fun setIgnoreFailures(ignoreFailures: Boolean): Unit

Whether or not to allow the build to continue if there are warnings. Example: ignoreFailures = true

setPmdClasspath

open fun setPmdClasspath(pmdClasspath: FileCollection): Unit

The class path containing the PMD library to be used.

setRulePriority

open fun setRulePriority(intValue: Int): Unit

Sets the rule priority threshold.

setRuleSetConfig

open fun setRuleSetConfig(ruleSetConfig: TextResource): Unit

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"))

setRuleSetFiles

open fun setRuleSetFiles(ruleSetFiles: FileCollection): Unit

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")

setRuleSets

open fun setRuleSets(ruleSets: MutableList<String>): Unit

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

setTargetJdk

open fun setTargetJdk(targetJdk: TargetJdk): Unit

The target JDK to use with PMD.

stdOutIsAttachedToTerminal

open fun stdOutIsAttachedToTerminal(): Boolean

validate

open static fun validate(value: Int): Unit

Validates the value is a valid PMD RulePriority (1-5)

Inherited Functions

exclude

open fun exclude(vararg excludes: String): SourceTask
open fun exclude(excludes: MutableIterable<String>): SourceTask
open fun exclude(excludeSpec: Spec<FileTreeElement>): SourceTask
open fun exclude(excludeSpec: Closure<Any>): SourceTask

{@inheritDoc}

getExcludes

open fun getExcludes(): MutableSet<String>

{@inheritDoc}

getIncludes

open fun getIncludes(): MutableSet<String>

{@inheritDoc}

include

open fun include(vararg includes: String): SourceTask
open fun include(includes: MutableIterable<String>): SourceTask
open fun include(includeSpec: Spec<FileTreeElement>): SourceTask
open fun include(includeSpec: Closure<Any>): SourceTask

{@inheritDoc}

setExcludes

open fun setExcludes(excludes: MutableIterable<String>): SourceTask

{@inheritDoc}

setIncludes

open fun setIncludes(includes: MutableIterable<String>): SourceTask

{@inheritDoc}

setSource

open fun setSource(source: FileTree): Unit

Sets the source for this task.

open fun setSource(source: Any): Unit

Sets the source for this task. The given source object is evaluated as per org.gradle.api.Project#files(Object...).

source

open fun source(vararg sources: Any): SourceTask

Adds some source to this task. The given source objects will be evaluated as per org.gradle.api.Project#files(Object...).