I have to run Sonarqube analysis for a Java project which is a subproject among 4 others, something like below:
Parent-project
-> serviceA
-> src/main/java/...
-> serviceB
-> src/main/java/...
-> serviceC
-> src/main/java/...
-> serviceD
-> src/main/java/...
-> gradle.properties
-> sonar.gradle
I know that I can exclude unwanted services as below:
project(":serviceB") {
sonarqube {
skipProject = true
}
}
However the problem is that I do not own the parent project and hence cannot make changes in the global sonar.gradle file as this is being shared other services as well.
Is there a way to have a sonar.gradle only for my project (serviceA), and a gradle task that runs analysis only for my service? I am completely lost here because the documentation does not seem to tell anything about this.
Any help will be highly appreciated!
I found a solution to this problem. You can actually exclude the unwanted projects under the parent project using following setting in your sonar.gradle:
project(":project-1") {
sonarqube {
skipProject = true
}
}
project(":project-2") {
sonarqube {
skipProject = true
}
}
If you want even more control to a level that you don't want to exclude a whole sub-project but want to include only a part of the sub-project (for example a common shared library where multiple teams contribute and you want to analyze just your team's code), you can do it something like below:
project(":common-project") {
sonarqube {
properties {
property "sonar.inclusions", "src/main/java/**/common/**"
}
}
}