Gradle PMD – Can’t find resource null

Gradle has support for PMD. You can find following example on internet:

apply plugin: 'pmd'

pmdMain {
  ruleSets = [ "basic", "strings" ]
}

This code is not working with Gradle 2.0. Here is error message:

:clean
:pmdMain FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':pmdMain'.
  Can't find resource null. Make sure the resource is a valid file or URL and is on the CLASSPATH. Here's the current classpath: C:\Users\georgik\tmp\install\gradle-2.0\lib\gradle-launcher-2.0.jar

The reason is simple. In case of Gradle 2.0 you must add language prefix before name of rule. You must use java-strings instead of plain strings.

Here is correct example (available also on YSoftDevs Github):

apply plugin: 'pmd'

pmdMain {
  ruleSets = [ "java-basic", "java-strings", "java-braces" ]
}

You can find more rules for PMD in official documentation.

Thanks Matt Sicker for correct solution.

No votes yet.
Please wait...

11. August 2014 at 21:25 - Software engineering (Tags: , , ).

  • Nice one – the null error did not really point towards this. Thanx for this – just made my day a lot better!

    No votes yet.
    Please wait...
  • Eugen Martynov

    Thank you a lot for solution

    No votes yet.
    Please wait...
  • Maxim

    The same! Thanks a lot of revealing source of problem

    No votes yet.
    Please wait...
  • Where is the fish?

  • Further info

  • Twitter

    Follow @jurajmichalek on twitter.

  • Comments

  • Tags

  • Topics