Gradle + Play + PMD/FindBugs


I’m using Gradle to compile my Play Framework 2.3.9 application including the play plugin provided. Until now everything is fine. The next step and a main issue for me is integrate the PMD and FindBugs plugin. It seems that the plugins assume that the source code is under the package “src” but according with the Play application anatomy, the source code is under “app”.

According with the plugins (PMD/FindBugs) documentation, we can configure the SourceSets but with the play plugin is not possible to set the SourceSets. I’m having the following error:

  • What went wrong:
    A problem occurred evaluating root project ‘xpto’.

Could not find method sourceSets() for arguments [build_eyo61lct2ravjcizs5vid9wim$_run_closure6@137734c6] on root project ‘xpto’.

If I remove the play plugin and add the java plugin, I can set the SourceSets to specify where the source code is and everything works great

sourceSets {
   main {
      java {
        srcDir 'app'

Anyone know how can I configure the PMD/FindBugs plugin to integrate with a Play plugin?

Doubtful it would work but you could try applying the java-base and scala-base plugins since these plugins add the source sets.

Applying the plugins in the following order:

 apply plugin: 'java-base'
 apply plugin: 'scala-base'
 apply plugin: 'play'

give me the following error:

A problem occurred configuring root project 'xpto'.

Exception thrown while executing model rule: PlayTestPlugin#attachTestSuitesToCheckTask
Cannot add rule PlayTestPlugin#attachTestSuitesToCheckTask > named(check) for model element ‘tasks.check’ at state Initialized as this element is already at state GraphClosed.

Any idea why?