How to setup sonar for multi-module gradle project?

Hi Guys,

I am trying to setup a java/kotlin multi module gradle project for analysis with circleci.
The project structure is as follows.

  • project1/build.gradle
  • project2/build.gradle
  • build.gradle

As of now I tried to build by including following property in root build.gradle. But when I check in sonar cloud, only one of the project gets appearing in code.

sonarqube {
     properties {
property "sonar.projectKey", "projeKey"
property "sonar.organization", "org"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.verbose", "true"
  }
}

gradle.txt (2.4 KB)

Hello @Vinod_plank,

I need some further clarification:

  • Do you wish to combine the analysis of all the modules into one project on SonarCloud or do you want to have one project on SonarCloud for every module?
  • How do you start the scan? Which command do you use?
  • Are there any relevant logs? Is it possible to share the output of the scan?

Hello Tom,
Yes, I wish to combine the analysis of all the modules into one project.
I start the scan from circleci using command gradle build sonarqube (Also tried gradle project1:build sonarqube)

There is not any logs. I see that all the sub modules are scanned in circleci but I see only one sub module in sonarcloud.

Hello @Vinod_plank,

The scanner always outputs logs, you can find them in the CircleCI build. They will help me finding out what is going on, if it contains some sensitive information you can share them through a private message.

This has been solved. I had applied sonar plugin and sonarqube block inside of subproject. I moved out of subproject module and now Sonar analyses all the module.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.