[GRADLE-632] PMD Ant task error when using rules from rulesets directory Created: 11/Sep/09  Updated: 04/Jan/13  Resolved: 24/Nov/10

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 0.9-rc-1

Type: Bug
Reporter: Tomek Kaczanowski Assignee: Adam Murdoch
Resolution: Fixed Votes: 0

Attachments: Zip Archive pmd.zip    

 Description   

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, while running PMD Ant task from Gradle build 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.

Attached is the project that illustrates this behaviour.


best regards
Tomek Kaczanowski



 Comments   
Comment by Alex Antonov [ 05/Jan/10 ]

Same problem exists on a 0.9 snapshots as well.

Comment by Hans Dockter [ 12/Jan/10 ]

We have changed the classloading behavior. See commit from Jan 7: http://github.com/gradle/gradle/commit/144847883d28134345be5e32bd2bcd8ba6303a2f

I get the following output now for the attached project:

:pmd
Running PMD static code analysis
No problems found!

BUILD SUCCESSFUL

Total time: 2.887 secs
Comment by Tomek Kaczanowski [ 22/Feb/10 ]

checked on the latest version (Gradle 0.9-20100222190125+0300)

it works fine

Generated at Wed Jun 30 11:34:53 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.