sonarRunner test dependency

I use sonarRunner in my gradle build script and it works very well unless a unit test fails. In that case gradle will not execute the sonarRunner taks (even with the --continue option), because it implicitly depends on test. I would say that this implicit dependency should not be there and that users of the plugin need to be aware that the tests have run before. Or am I missing something?

Good point. Previously, people complained that ‘gradle sonarAnalyze’ does not run ‘compile’ and ‘test’, but the situation you describe is the bigger evil. We may have to remove the task dependency, or change it into one of the new task relationships introduced in Gradle 1.6+. Meanwhile, you can get rid of the unwanted dependency with ‘tasks.sonarRunner.dependsOn = []’.

Ran into a related problem (a 3rd party library collected the coverage metrics, which causes executing the tests and uploading sonar to be disjoint), thanks to both of you for the quick fix.

I went a small step further and switched it to use the mustRanAfter construct.

tasks.sonarRunner.dependsOn = []
1 Like

The current gradle (version 2.2.1) still has this “feature”. Is there any plan to change it?

It’s an open issue (see GRADLE-2749).