Could you add a JIRA issue for this?
An untested workaround is to fiddle with the ant classloader:
def cl = ant.taskdef(...).createLoader()
cl.parentFirst = false
// might also need
cl.addJavaLibraries()
Tomek Kaczanowski wrote:
hi all,
In general running PMD from Gradle it works fine, but there is one
strange thing that bothers me.
You need to configure PMD and tell it, what rules should be used by
passing rulesetfiles parameter (if you are curious about the whole
script, have a look here:
http://docs.codehaus.org/display/GRADLE/Cookbook#Cookbook-usingPMD).
So, you can put a file into "conf/myrules.xml" and than pass it like this:
pmd(shortFilenames:'true', failonruleviolation:'true',
rulesetfiles:'conf/pmd-rules.xml') {
... more config here, not important
}
So far so good.
Now, PMD comes with a lot of predefined rule files. They are included
in the PMD jar in rulesets dir, so they are available on the classpath
of the Ant PMD task. So, this should work:
pmd(shortFilenames:'true', failonruleviolation:'true',
rulesetfiles:'rulesets/basic.xml') {
... more config here, not important
}
but it fails with the following output:
Execution failed for task ':pmd'.
Cause: java.lang.ClassCastException:
org.codenarc.rule.basic.BooleanInstantiationRule cannot be cast to
net.sourceforge.pmd.Rule
As you can see, PMD tries to open the file that is provided by
CodeNarc (which is part of the Gradle distribution). Unfortunately,
both projects - PMD and Codenarc - keep their ruleset files in the
same dir - "rulesets". If you choose name of the ruleset that exists
in PMD but doesn't exist in CodeNarc (like "clone.xml") than
everything works fine, PMD picks the right file.
So, the question is, is it possible to change the "order" on the
classpath, so PMD will look first into itself and not into CodeNarc ?
It is not a blocker (you can always copy ruleset files to some dir and
use it from there), but PMD users will likely expect it to work "just
like that" and will be suprised.
Tested on latest snapshot - Gradle 0.8-20090909213706+0200
Attached is the project that illustrates this behaviour.
--
best regards
Tomek Kaczanowski
------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email