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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Task
Task.Namer -
Field Summary
Fields inherited from class SourceTask
sourceFields inherited from interface Task
TASK_ACTION, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.gradle.api.internal.project.IsolatedAntBuilderCompile class path for the classes to be analyzed.booleanWhether or not to allow the build to continue if there are warnings.Injects and returns an instance ofObjectFactory.The class path containing the PMD library to be used.final PmdReportsThe reports to be generated by this task.intSpecifies the rule priority threshold.The custom rule set to be used (if any).The custom rule set files to be used.The built-in rule sets to be used.Returns the source for this task, after the include and exclude patterns have been applied.The target JDK to use with PMD.booleanWhether or not to write PMD results toSystem.out.Configures the reports to be generated by this task.reports(Action<? super PmdReports> configureAction) Configures the reports to be generated by this task.voidrun()voidsetClasspath(FileCollection classpath) Compile class path for the classes to be analyzed.voidsetConsoleOutput(boolean consoleOutput) Whether or not to write PMD results toSystem.out.voidsetIgnoreFailures(boolean ignoreFailures) Whether or not to allow the build to continue if there are warnings.voidsetPmdClasspath(FileCollection pmdClasspath) The class path containing the PMD library to be used.voidsetRulePriority(int intValue) Sets the rule priority threshold.voidsetRuleSetConfig(TextResource ruleSetConfig) The custom rule set to be used (if any).voidsetRuleSetFiles(FileCollection ruleSetFiles) The custom rule set files to be used.voidsetRuleSets(List<String> ruleSets) The built-in rule sets to be used.voidsetTargetJdk(TargetJdk targetJdk) The target JDK to use with PMD.booleanstatic voidvalidate(int value) Validates the value is a valid PMD RulePriority (1-5)Methods inherited from class SourceTask
exclude, exclude, exclude, exclude, getExcludes, getIncludes, getPatternSetFactory, include, include, include, include, setExcludes, setIncludes, setSource, setSource, sourceMethods inherited from class org.gradle.api.internal.ConventionTask
conventionMapping, conventionMapping, getConventionMappingMethods inherited from class DefaultTask
newInputDirectory, newInputFile, newOutputDirectory, newOutputFileMethods 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
-
Pmd
public Pmd()
-
-
Method Details
-
getObjectFactory
Injects and returns an instance ofObjectFactory.- Since:
- 4.2
-
getAntBuilder
@Inject public org.gradle.api.internal.project.IsolatedAntBuilder getAntBuilder() -
run
public void run() -
stdOutIsAttachedToTerminal
public boolean stdOutIsAttachedToTerminal() -
reports
Configures the reports to be generated by this task.- Specified by:
reportsin interfaceReporting<PmdReports>- Parameters:
closure- The configuration- Returns:
- The report container
-
reports
Configures the reports to be generated by this task.- Specified by:
reportsin interfaceReporting<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
Returns the source for this task, after the include and exclude patterns have been applied. Ignores source files which do not exist.- Overrides:
getSourcein classSourceTask- Returns:
- The source.
-
getPmdClasspath
The class path containing the PMD library to be used. -
setPmdClasspath
The class path containing the PMD library to be used. -
getRuleSets
The built-in rule sets to be used. See the official list of built-in rule sets. Example: ruleSets = ["basic", "braces"] -
setRuleSets
The built-in rule sets to be used. See the official list of built-in rule sets. Example: ruleSets = ["basic", "braces"] -
getTargetJdk
-
setTargetJdk
The target JDK to use with PMD. -
getRuleSetConfig
The custom rule set to be used (if any). ReplacesruleSetFiles, 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
The custom rule set to be used (if any). ReplacesruleSetFiles, 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
-
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
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") -
getReports
The reports to be generated by this task.- Specified by:
getReportsin interfaceReporting<PmdReports>- Returns:
- The report container
-
getIgnoreFailures
public boolean getIgnoreFailures()Whether or not to allow the build to continue if there are warnings. Example: ignoreFailures = true- Specified by:
getIgnoreFailuresin interfaceVerificationTask- Returns:
- false, when the build should break on failure, true when the failures should be ignored.
-
setIgnoreFailures
public void setIgnoreFailures(boolean ignoreFailures) Whether or not to allow the build to continue if there are warnings. Example: ignoreFailures = true- Specified by:
setIgnoreFailuresin interfaceVerificationTask- Parameters:
ignoreFailures- false to break the build on failure, true to ignore the failures. The default is false.
-
getRulePriority
Specifies the rule priority threshold.- Since:
- 2.8
- See Also:
-
setRulePriority
-
isConsoleOutput
Whether or not to write PMD results toSystem.out.- Since:
- 2.1
-
setConsoleOutput
Whether or not to write PMD results toSystem.out.- Since:
- 2.1
-
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
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
-