I wonder if having ‘ruleSets’ default to ‘basic’ is a good idea. I use a custom ruleset, which I specify with ‘ruleSetFiles’; however, it only includes some of the basic.xml rules. As my code violated some of the basic.xml rules I did not have in my custom ruleset, my build failed until I added “ruleSets = []” too.
Is there a way to exclude some source from being checked? The checkstyle and codenarc plugins seem to have the concept of “exclude”; however, that seems to be missing here. I have one legacy project that has some code I’d like to not check, but some other code I want to check. This was possible with the PMD Ant task I was using previously. Am I missing something? If not, are there plans to expose this in the DSL by/before 1.0?
As i mentioned, I did not see “exclude” documented anywhere in relation to the PMD plugin. When I change my configuration to add the exclude as you suggest, it looks like this:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/jbisotti/sandbox/dm-core/build.gradle' line: 265
* What went wrong:
A problem occurred evaluating root project 'dm-core'.
> Could not find method exclude() for arguments [**/npaparser/**/*.java] on org.gradle.api.plugins.quality.PmdExtension_Decorated@1a15597.
Also, I’m not sure what the difference between “pmd {” and “tasks.pmd {” is, but the latter doesn’t work for me at all – it complains as follows:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/jbisotti/sandbox/dm-core/build.gradle' line: 261
* What went wrong:
A problem occurred evaluating root project 'dm-core'.
> Could not find method pmd() for arguments [build_5epactb68o6hnndhnp1kidej0i$_run_closure1_closure16@1571dff] on task set.
On a related note, are these code quality “things” really tasks? I tried to add
‘pmd {}’ is an extension object brought in by the PMD plugin. It provides a simplified and higher-level way of configuring the PMD tasks. Things like ‘exclude’ and ‘onlyIf’ have to be configured on the tasks themselves. I had though that the task for the main source set is also called ‘pmd’, in which case you would have had to disambiguate with ‘tasks.pmd’. However, I was wrong and the task is called ‘pmdMain’. Hence you can just do:
I used pmdMain to exclude the pattern in the legacy sub-project’s build.gradle and that seems to have done the trick. However, I’m still not clear if this is a temporary work-around or just “the way” to do this. ???