I have a gradle project with some codes in src/main/java
and some unit tests in src/test/java
Below is snippet from build.gradle
apply plugin: "jacoco"
sourceSets {
main {
java { srcDir 'src/main/java' }
}
}
test {
jacoco {
append = false
destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
classDumpDir = file("$buildDir/jacoco/classpathdumps")
}
}
jacoco {
toolVersion = "0.7.8"
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/reports/jacoco/jacocoHtml"
}
}
On TeamCity, I have 2 steps, first is Gradle step with command gradle clean jacocoTestReport build
and second step is SonarQube runner with the following parameters:
-Dsonar.sources=%system.teamcity.build.checkoutDir%/src
-Dsonar.java.binaries=%system.teamcity.build.checkoutDir%/build/classes
-Dsonar.branch.name=%teamcity.build.branch%
-Dsonar.jacoco.reportPaths=%system.teamcity.build.checkoutDir%/build/jacoco/jacocoTest.exec
However, on SonarQube dashboard, my project still shows to have 0% Coverage. Please advise me if I feed jacoco
coverage report correctly to SonarQube (Version 6.7)