Quality plugin configuration. Available as 'quality' closure.
| Type | Name and description |
|---|---|
java.lang.String |
animalsnifferVersionSets AnimalSniffer version. |
boolean |
autoRegistrationAutomatically register quality plugins, based on configured (affected) sources (sourceSets). |
boolean |
checkstyleEnable Checkstyle plugin. |
java.lang.String |
checkstyleVersion |
boolean |
codenarcEnable CodeNarc plugin. |
java.lang.String |
codenarcVersion |
java.lang.String |
configDirConfiguration files directory. |
boolean |
consoleReportingWhen false, disables reporting quality issues to console. |
boolean |
cpdEnable auto configuration of de.aaschmid.cpd plugin (if applied). |
boolean |
cpdUnifySourcesBy default, cpd looks in all sources (cpd gradle plugin behaviour). |
boolean |
enabledWhen false, disables quality tasks execution. |
java.util.Collection<java.lang.String> |
excludeSource patterns (relative to source dir) to exclude from checks. |
org.gradle.api.file.FileCollection |
excludeSourcesDirect sources to exclude from checks (except animalsniffer). |
boolean |
htmlReportsWhen false, no html report will be built. |
java.util.List<java.lang.String> |
lintOptionsJavac lint options to show compiler warnings, not visible by default. |
boolean |
pmdEnable PMD plugin. |
boolean |
pmdIncrementalEnable PMD incremental analysis (cache results between builds to speed up processing). |
java.lang.String |
pmdVersion |
java.util.Collection<org.gradle.api.tasks.SourceSet> |
sourceSetsSource sets to apply checks on. |
boolean |
spotbugsEnable SpotBugs plugin. |
java.lang.String |
spotbugsEffortThe analysis effort level. |
java.lang.String |
spotbugsLevelThe priority threshold for reporting bugs. |
java.lang.String |
spotbugsMaxHeapSizeMax memory available for spotbugs task. |
int |
spotbugsMaxRankSpotbugs rank should be an integer value between 1 and 20, where 1 to 4 are scariest, 5 to 9 scary, 10 to 14 troubling, and 15 to 20 of concern bugs. |
java.util.Set<java.lang.String> |
spotbugsPluginsShortcut for spotbugs plugins declaration without using afterEvaluate block. |
java.lang.String |
spotbugsVersion |
boolean |
strictStrict quality leads to build fail on any violation found. |
| Constructor and description |
|---|
QualityExtension
(org.gradle.api.Project project) |
| Type Params | Return Type | Name and description |
|---|---|---|
|
void |
exclude(java.lang.String... patterns)Shortcut for exclude |
|
void |
spotbugsPlugin(java.lang.String plugin)Shortcut for spotbugs plugin registration (spotbugsPlugins). |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Sets AnimalSniffer version. Works only when 'ru.vyarus.animalsniffer' plugin applied.
Automatically register quality plugins, based on configured (affected) sources (sourceSets). For example, if configured sources contain only java sources then only pmd, checkstyle and spotbugs plugins will be activated; if only groovy sources - then codenarc only.
When disabled, quality plugins must be registered manually. Only registered plugins will be configured if configuration is not disabled with plugin flags (pmd, checkstyle etc.). True by default.
Enable Checkstyle plugin. True by default. If plugin enabled manually then disabling this option will prevent applying plugin configuration.
Enable CodeNarc plugin. Ignored if groovy plugin is not applied). True by default. If plugin enabled manually then disabling this option will prevent applying plugin configuration.
Configuration files directory. It may contain custom plugin configurations (not required). By default its gradle/config/.
When false, disables reporting quality issues to console. Only gradle general error messages will remain in logs. This may be useful in cases when project contains too many warnings. Also, console reporting require xml reports parsing, which could be time consuming in case of too many errors (large xml reports). True by default.
Enable auto configuration of de.aaschmid.cpd plugin (if applied). CPD is a part of PMD and so should share the same version. Cpd plugin will not be configured at all if option set to false.
As cpd plugin is applied manually, then all other cpd configuration may be performed in cpd closure directly (without "afterEvaluate"). Plugin will affect only ignoreFailures, toolVersion, enable xml report and change cpdCheck task sources (see cpdUnifySources). cpdCheck task is always linked to check task. In case of multi-module project it means that sub module check will call cpdCheck declared in root project (because module check must also check for potential new duplicate parts).
By default, cpd looks in all sources (cpd gradle plugin behaviour). When option enabled, quality plugin will exclude all not configured source sets from cpd task sources. In case of multi-module build, where cpd project declared in root project, all subprojects with quality plugin will exclude their sourceSets not configured for quality checks. Also, all custom exclusions (exclude, excludeSources) will also be excluded.
When disabled, cpdCheck task sources will not be modified (and so cpd will check all source sets without manual configuration).
When false, disables quality tasks execution. Allows disabling tasks without removing plugins. Quality tasks are still registered, but skip execution, except when task called directly or through checkQualityMain (or other source set) grouping task. True by default.
Source patterns (relative to source dir) to exclude from checks. Simply sets exclusions to quality tasks.
Animalsniffer is not affected because it's a different kind of check (and, also, it operates on classes so source patterns may not comply).
Spotbugs does not support exclusion directly, but plugin will resolve excluded classes and apply them to xml exclude file (default one or provided by user).
Cpd plugin (if applied) will also be affected.
By default nothing is excluded.
IMPORTANT: Patterns are checked relatively to source set dirs (not including them). So you can only match source files and packages, but not absolute file path (this is gradle specific, not plugin).
Direct sources to exclude from checks (except animalsniffer). This is useful as last resort, when extension or package is not enough for filtering. Use Project#files(java.lang.Object) or Project#fileTree(java.lang.Object) to create initial collections and apply filter on it (using org.gradle.api.file.FileTree#matching(groovy.lang.Closure)).
Plugin will include files into spotbugs exclusion filter xml (default one or provided by user).
Exclusions will also be applied to cpd plugin (if plugin applied).
Note: this must be used when excluded classes can't be extracted to different source set and filter by package and filename is not sufficient.
When false, no html report will be built. By default, html reports are always built.
Javac lint options to show compiler warnings, not visible by default. By default enables deprecation and unchecked options. Applies to all JavaCompile tasks. Full list of options: http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html#BHCJCABJ
Enable PMD plugin. True by default. If plugin enabled manually then disabling this option will prevent applying plugin configuration.
Enable PMD incremental analysis (cache results between builds to speed up processing).
This is a shortcut for pmd plugin's pmd.incrementalAnalysis configuration option.
Option is disabled by default due to possible side effects with build gradle cache or incremental builds.
Source sets to apply checks on. Default is [project.sourceSets.main] to apply only for project sources, excluding tests.
Enable SpotBugs plugin. True by default. If plugin enabled manually then disabling this option will just prevent applying plugin configuration.
The analysis effort level. The value specified should be one of min, default, or max. Higher levels increase precision and find more bugs at the expense of running time and memory consumption. Default is 'max'.
The priority threshold for reporting bugs. If set to low, all bugs are reported. If set to medium, medium and high priority bugs are reported. If set to high, only high priority bugs are reported. Default is 'medium'.
Max memory available for spotbugs task. Note that in gradle 4 spotbugs task maximum memory was 1/4 of physical memory, but in gradle 5 it become only 512mb (default for workers api). To minify impact of this gradle 5 change, default value in extension is 1g now, but it may be not enough for large projects (and so you will have to increase it manually).
IMPORTANT: setting will not work if heap size configured directly in spotbugs task (for example, with
spotbugsMain.maxHeapSize = '2g'. This was done in order to not break current behaviour
(when task memory is already configured) and affect only default cases (mostly caused by gradle 5 transition).
See: https://github.com/gradle/gradle/issues/6216 (Reduce default memory settings for daemon and workers).
Spotbugs rank should be an integer value between 1 and 20, where 1 to 4 are scariest, 5 to 9 scary, 10 to 14 troubling, and 15 to 20 of concern bugs.
This option allows you to filter low-priority ranks: for example, setting spotbugsMaxRank=15 will
filter all bugs with ranks 16-20. Note that this is not the same as spotbugsLevel:
it has a bit different meaning (note that both priority and rank are shown for each spotbugs
violation in console).
The only way to apply rank filtering is through exclude filter. Plugin will automatically generate additional rule in your exclude filter or in default one. But it may conflict with manual rank rule declaration (in case if you edit exclude filter manually), so be careful when enabling this option.
Shortcut for spotbugs plugins declaration without using afterEvaluate block. All registered plugins will be simply added to spotbugsPlugins configuration. May be used together with direct configuration (default way).
Property is not supposed to be used directly. Instead, plugins should be registered using spotbugsPlugin(java.lang.String) to mimic default spotbugs configuration.
Strict quality leads to build fail on any violation found. If disabled, all violation are just printed to console (if console reporting enabled). True by default.
Shortcut for exclude
patterns - exclusion patterns (relative to source root)Shortcut for spotbugs plugin registration (spotbugsPlugins). Essentially equivalent to normal plugin declaration directly in 'spotbugsPlugins` configuration (as dependency).
plugin - plugin dependencyGroovy Documentation