I'm working on adding these plugins to Gradle proper.  However, I'm running
into classpath issues with the PMD plugin.  I'm not an expert on this stuff,
so I was hoping someone here might be able to help.

The situation arises when executing the PMD task while referencing the
standard rulesets included in the PMD distribution.  The task fails with a
ClassCastException because it is trying to include CodeNarc's rulesets
rather than PMDs.  They both have rulesets in XML files underneath a
rulesets folder directly in the root of their JAR (and both have a
basic.xml).  This was not an issue when these classes were in a separate
plugin JAR loaded through the normal buildscript {} block. I assume there's
an extra layer of classloaders in that case, but haven't been able to
confirm it.

Basically, I'm wondering what the correct approach for this is.  Is there a
way to execute the PMD Ant task isolated from some of the other classes
available on Gradle's classpath?

You can reproduce this with the PMDIntegrationTest class added to the
integTest subproject in my fork below.

I'm working on this branch in my fork:
https://github.com/ajoberstar/gradle/tree/code-quality
Here's the most relevant commit:
https://github.com/ajoberstar/gradle/commit/cf7bd46837e22f8cb0a6ec58ed93f78beae82aa9

Andy Oberstar


On Sun, May 15, 2011 at 3:51 PM, Adam Murdoch
<[email protected]>wrote:

>
> On 15/05/2011, at 2:53 AM, Andrew Oberstar wrote:
>
> Hi all,
>
> I just released a few Gradle plugins for JDepend, PMD, and Findbugs.  As
> far as I could tell (I may be wrong), there aren't any pure plugins for
> these tools.  The code was mostly inspired by the samples in the Cookbook
> and the code-quality plugin.  The implementations aren't that great, but
> they work for the most part.  This is my first crack at this, so I welcome
> any comments, suggestions, or criticism.
>
>
> These look really good. You should list the plugins on the wiki:
> http://wiki.gradle.org/display/GRADLE/Plugins
>
> Here are a few things you could do to simplify the code:
>
> - In JDepend, you can remove the onlyIf check added in the constructor, and
> replace it with @SkipWhenEmpty on getClassesDir().
>
> - You could make Findbugs.classpath and classes with @InputFiles instead of
> @Input. Same for PMD.rulesets. You get some better validation and the
> up-to-date checking is potentially faster when Gradle knows these are input
> files. On the other hand, this is also something Gradle could figure out
> from the types of the properties, so perhaps we should change Gradle in this
> instance.
>
>
> --
> Adam Murdoch
> Gradle Co-founder
> http://www.gradle.org
> VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
> http://www.gradleware.com
>
>

Reply via email to