Ability to disable automatic task dependence in Gradle Sonar Plugin


(Kevin Brooks) #1

The task dependence injected by the Gradle Sonar Plugin assumes that the project conforms to idealistic standards and that test coverage is to be included.
However, for projects which do not conform to these standards, or for those which wish to only complete static code analysis, the ‘out-of-the-box’ task dependence can be undesirable.
It would be fairly simple and straightforward (I would be happy to do the work myself) to permit the ‘disabling’ of the automatic task dependence, placing the responsibility of dependency specification on the build script.

(Julien Henry) #3

Hi Kevin,

I can understand the problem for advanced use cases, so a contribution would be welcome. But before you start, isn’t it possible using Gradle API to disable the task dependency ‘dynamically’ from your build script, without having to introduce a new parameter in the plugin?

(Kevin Brooks) #4

Hi @Julien_HENRY,
Although possible we’re concerned with maintainability.
To replicate the desired behavior simply and consistently, one would overwrite all existing dependencies with the tasks they desire.
Suppose the Sonar Gradle project introduces a new (internal) task dependency in an updated release - external task dependency management may (depending on the implementation) then need to take this into account.

(Julien Henry) #5

Hi Kevin,

What about sonarqube.dependsOn.remove("test") as mentioned here:

Or maybe https://discuss.gradle.org/t/remove-task-dependency/18493

(Kevin Brooks) #6

Because the compilation targets are an issue as well.
We still have some compilation occurring in imported ant builds, which breaks the assumed dependency chain on test.

(Kevin Brooks) #7

Additionally, I don’t think that will work correctly, or at least consistently, with the way the SonarQube task is configuring it’s dependencies (as a callable) -> https://github.com/SonarSource/sonar-scanner-gradle/blob/master/src/main/java/org/sonarqube/gradle/SonarQubePlugin.java#L92-L96

(Julien Henry) #9

Sorry for the late answer on this thread, but I have created a ticket to remove this dependency in the next major version of the SonarQube Gradle plugin: