I have a ruleset file (config/PMD/includeRuleset.xml) for PMD which refers to the ruleset files supplied with PMD (like rulesets/java/basic.xml). I have configured Gradle to use my ruleset file:
When I run the ‘check’ target I get: java.lang.RuntimeException: Couldn’t find that class Can’t find resource rulesets/java/basic.xml. Make sure the resource is a valid file or URL or is on the CLASSPATH
So Gradle cannot find the standard rule sets supplied with PMD when they are referred through my own ruleset file.
I need this to have common PMD configuration used both by Gradle and Eclipse.
How can I solve this problem ?
Shouldn’t it be considered a bug that I can’t fine tune the rules configuration of PMD using a ruleset file ?
I can see from the API documentation that I can set a classpath containing my own PMD libraries which I think must be java classes containing rules but I wouldn’t expect it to be necessary to set the classpath for the libraries and rule set files which come together with the PMD executable.
I’m not particularly familiar with the PMD plugin, but it’s not too much more than a wrapper around the PMD Ant task. If you’ve got the Ant task working, you might be able to see what’s different in the Gradle plugin here.
If you do sort it out, a patch addressing this issue would be most welcome.
I’m on Gradle 1.6 and with the below simple configuration I’m seeing a similar exception as Esben:
pmd {
toolVersion = ‘5.0.3’
ruleSets = [“basic”, “braces”]
}
The text of the exception I get is:
Can’t find resource null. Make sure the resource is a valid file or URL or is
on the CLASSPATH. Here’s the current classpath: c:\Path\to\wrapper\wrapper.jar
It seems like any specified ruleSets causes the issue (I’ve tried just one entry with basics). I have yet to try a custom ruleSetFiles. Running without ruleSets generates a report appropriately.