IllegalArgumentException after upgrading to PMD 5.2.0

I upgraded to 5.2.0, and now I get “java.lang.IllegalArgumentException: Unknown Language ‘java’ for Rule JumbledIncrementer, supported Languages are” [empty].

Here’s my config:

apply plugin: ‘pmd’

dependencies {

pmd(

‘net.sourceforge.pmd:pmd-core:5.2.0’,

‘net.sourceforge.pmd:pmd-java:5.2.0’

)

}

Do you explicitly configure any PMD rulesets? Also, can you try ‘pmd.toolVersion = “5.2.0”’ instead of explicitly declaring PMD dependencies?

With …

apply plugin: ‘pmd’

pmd.toolVersion = ‘5.2.0’

… I get “java.lang.ClassNotFoundException: net.sourceforge.pmd.ant.PMDTask”

Here’s our ruleset: http://pastebin.com/8GbJXJ1i

PMD 5 renamed the ‘java’ ruleset to ‘java-basic’. Perhaps ‘java’ is no longer supported as of 5.2.0, and you have to update the references in your ruleset file. The CNFE indicates that there is some work for us to do to be compatible with 5.2.0. I’ve raised GRADLE-3186 for this. Thanks for the report.

Thanks for looking at this. I don’t declare the JumbledIncrementer ruleset myself, so I don’t think updating my references will help.

At first sight, I don’t think that the IllegalArgumentException is something that can be fixed on Gradle’s side. However, at this point this is just a guess.

This has now been fixed in PMD 5.2.1

But pmd.toolVersion = ‘5.2.1’ doesn’t work, I still have to declare the dependency as described above.

‘pmd.toolVersion = ‘5.2.1’’ will add the all-in-one ‘net.sourceforge.pmd:pmd:5.2.1’ rather than ‘-core’ and ‘-java’, and it looks like the bug wasn’t fixed for that distribution.