Reputation: 93
I have seen different approaches with different specification: only java, only single module, with jacoco exec file or xml report for sonarqube, sonarqube.gradle included in all modules or only in root.... and tried a lot. At the end I struggled always and some of my requirements don't work.
Does anyone have an approach that fit all my needs?
Upvotes: 4
Views: 2350
Reputation: 93
I have created a test project which fill all my needs in my github repo
The key facts are that you have to put you sonar task in your root gradle file and the jacoco one at any module in your project.
The important sonar properties are:
sonar.host.url
and sonar.coverage.jacoco.xmlReportPaths
For the jacoco task you have to define your java-Classes "../app/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/de/logerbyte/jacocotest/javaClasses"
, your kotlin-Classes "../app/build/tmp/kotlin-classes/debug/de/logerbyte/jacocotest"
and your normal src "../app/src/main/java"
for every module.
With these information you have to set the properties classDirectories
, executionData
and sourceDirectoriers
in your own created jacoco task.
At the end you run the gradle tasks for build
, testDebugUnitTest
, jacocoTestReport
and sonarqube
.
Upvotes: 2