4

Sonar scanner - 3.1

Java 1.7

I'm trying to configure sonar properties to get coverage from a multi-module project. Coverage is generated under the path: Module/build/jacoco/test.exec, so I wanted to add it to sonar.properties file according to documentation:

https://docs.sonarqube.org/display/PLUG/Code+Coverage+by+Unit+Tests+for+Java+Project

sonar.java.coveragePlugin=jacoco

sonar.jacoco.reportPaths=**/build/jacoco/*.exec

I was trying different combinations even with the absolute path but it seems that sonar-scanner doesn't see this property at all and always looks at default path. I'm always getting information in the logs that:

INFO: JaCoCoSensor: JaCoCo report not found : path\target\jacoco.exec

INFO: JaCoCoSensor: JaCoCo IT report not found: path\target\jacoco-it.exec

It does read other properties from the file like login, password, language, sources etc.

Also, the project is based on Gradle.

Ramesh
  • 340
  • 1
  • 7
  • 21
Lobo
  • 183
  • 1
  • 2
  • 8

2 Answers2

1

If you're building with Gradle, you should Analyze with Gradle. Specifically, there's no need for a sonar-project.properties file. Instead, you configure the SonarQube plugin in your build.gradle, and most of this should just work.

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
  • So I was trying to do it with gradle actually, I have made configuration for all other projects that support Java 8. It works perfectly and configuration is simple and clear, but when it comes to projects in java 7 im getting version collision between project and sonarqube that is not supporting java 7. So project needs to be built in Java 7 to be scanned and sonarqube requires java 8 which gives me standard java error: Unsupported major.minor version 52.0. Our server version is set also set for Java 8 as far as I know. Is there something I'm missing and better way to do it? – Lobo Apr 05 '18 at 17:57
1

Which version of the Sonar do you use ? If the version is under 6.2 you have to use sonar.jacoco.reportPath (without the s).

I don't think wildcards are accepted so if the exec is under the path Module/build/jacoco/test.exec, the parameter shoud be :sonar.jacoco.reportPath=build/jacoco/test.exec

Alban
  • 123
  • 1
  • 1
  • 5