How to SCAN and check code coverage of multiple modules in same project

Hello wonderful people, I am quite stuck on this project where I need to run Sonarqube scan on multiple directories. For a single module project I can use this to get the scan done and codecoverage.

jacocoTestReport { reports { xml.enabled true } }
sonarqube {
    properties {
        property "sonar.host.url", "http://www.sonarqube.test.com" //  url is your sonar server
        property "sonar.projectName", "app"   //  this name will appear in dashboard
        property "sonar.projectKey", "com.app.test"
        // It sould be a keybased on this report is created
        property "sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/test/jacocoTestReport.xml"
        property "sonar.java.binaries", "build/classes/java/main"
        property "sonar.java.coveragePlugin", "jacoco"
    }
}

But now my project hierarchy is
|
->account
| |->src
| |->build.gradle
|
->example
| |->scr
| |->build.gradle
|
->setting.gradle

In account, I am having src and build.gradle. Similarly, In example as well.
Also, I want to use the same project(same projectkey) in sonar.xxx.com.
I found a link where someone suggested using separate projectkeys for each module.

Hi @Vikas_Rathore ,

We have this guide but it doesn’t address Gradle multimodule projects like yours: [Coverage & Test Data] Importing JaCoCo coverage report in XML format

Please see my example here: sonar-scanning-examples/sonarqube-scanner-gradle/gradle-multimodule-coverage at master · SonarSource/sonar-scanning-examples · GitHub

Scroll down and read how I did it in my example in the “Coverage” section.

Regards,
Joe