2

I have a multi-module gradle project created in android studio and want to run an analysis using sonarqube. The project structure is as below root (no source files) Module 1 com.myapp.module1 package1 package2

Module 2 (structure similar to that of Module 1)

I added the sonarqube plugin in the build.gradle file in root along with the following sonarqube properties: a) Host URL b) jdbc url c) Username for jdbc d) password for jdbc

I use gradlew for the build. When I run gradlew sonarqube from my root directory, sonarqube runs but indicates that 0 files are indexed for all the modules.

What am I missing here? It should be something fairly obvious but I have not been able to find an answer in the existing stackoverflow archives.

  • Looks like I messed up the formatting when I tried to present the folder hierarcy. To clarify, the root folder does not have any source files. Under each module, I have a set of packages (com.app.,module.package1...) containing the respective java files. – user3393745 Jul 16 '15 at 16:55
  • We do not automatically support Android projects yet in Gradle plugin. So you may have to manually define properties like sonar.sources to have your files correctly indexed. – Julien H. - SonarSource Team Jul 16 '15 at 19:36
  • Any guidance or pointers on sonar.sources? I tried the following that did not work: sonar.sources=android.sourceSets.main.java.srcDirs – user3393745 Jul 17 '15 at 13:17
  • Ok - got it working. I had to set sonar.sources under each of my module. Maybe a beginner's error. Thanks for the help anyways. – user3393745 Jul 17 '15 at 14:47

2 Answers2

3

I had to explicitly have sonar.sources property in each of the module.

sonarqube { properties { properties["sonar.sources"] += "src" } }

  • Does it work if you configure it once in the root project using `subprojects` statement? http://docs.sonarqube.org/display/SONAR/Analyzing+with+Gradle#AnalyzingwithGradle-Sharedconfigurationsettings – Julien H. - SonarSource Team Jul 17 '15 at 19:44
0

you dont have to put sonar.sources in each module

Check my answer in this link,it worked for me:

What is the correct way to configure an Android project with submodules for use with the sonarqube gradle plugin?

Community
  • 1
  • 1
Amal p
  • 2,882
  • 4
  • 29
  • 49