3
votes

I have a multi-module gradle project. Tests for one of my module are in separate modules. For ex: ProjectA, ProjectATest1, ProjectATest2, ProjectATest3. Jacoco execution reports are getting created in the test projects. I want to do sonar analysis of my ProjectA and sonar fails to find the jacoco files.

in ProjectA, sonarqube properties, I gave

sonarqube{
    properties {
      property "sonar.jacoco.reportPaths","ProjectATest1/gradleBuild/jacoco/Tests.exec", "ProjectATest2/gradleBuild/jacoco/Tests.exec", "ProjectATest3/gradleBuild/jacoco/Tests.exec" 
    }
}

But I get this exception

Could not find method property() for arguments [sonar.jacoco.reportPaths,"ProjectATest1/gradleBuild/jacoco/Tests.exec", "ProjectATest2/gradleBuild/jacoco/Tests.exec", "ProjectATest3/gradleBuild/jacoco/Tests.exec"]

SonarQube: Coverage incomplete on multimodule gradle project with JaCoCo the answer says it should work. Is there a bug in sonar gradle plugin?

1
I got it fixed by using jacoco merge and merging the files into single file. While it works for me, I wish it worked right out of the box. github.com/BolderTechnologies/SonarQube-TotalCoverageuser281693
I just realized that I passed the arguments wrong. All 3 should have been in one argument. Duh.user281693

1 Answers

2
votes

Could not find method property() for arguments [sonar.jacoco.reportPaths,"ProjectATest1/gradleBuild/jacoco/Tests.exec", "ProjectATest2/gradleBuild/jacoco/Tests.exec", "ProjectATest3/gradleBuild/jacoco/Tests.exec"]

It means that the method property disallow passing 4 arguments. You have to define paths in a one string (comma separated list):

sonarqube{
  properties {
    property "sonar.jacoco.reportPaths", "ProjectATest1/gradleBuild/jacoco/Tests.exec,ProjectATest2/gradleBuild/jacoco/Tests.exec,ProjectATest3/gradleBuild/jacoco/Tests.exec" 
  }
}