0

I've got a multimodule Gradle 4.6 project and Sonarqube 7. Sonarqube and Jacoco are configured as follows:

apply plugin: 'org.sonarqube'

sonarqube {
    properties {
        property 'sonar.host.url', sonarHostUrl
        property 'sonar.jacoco.reportPaths', "$buildDir/reports/jacoco"
    }
}

apply plugin: 'jacoco'

jacoco {
    toolVersion = "0.7.9"
}

jacocoTestReport {
    group = "Reporting"
    reports {
        xml.enabled true
        xml.destination "${buildDir}/reports/jacoco/report.xml"
        csv.enabled false
        html.enabled true
    }
}

test {
    jacoco {
        append = true
    }
}

I'm running build and sonar with the following commands:

./gradlew clean build jacocoTestReport --info

./gradlew sonarqube -Dsonar.branch=nonMasterBranch --info

I expect it go aggregate Sonar report and show me a single project in Sonarqube (I'm using append=true in the jacoco configuration). However, I'm getting a project per module that is very messy.

Thank you very much for any ideas! I've been working with this hell task for too much time and no thoughts:C

ToYonos
  • 16,469
  • 2
  • 54
  • 70
Dmitry Senkovich
  • 5,521
  • 8
  • 37
  • 74

1 Answers1

0

According to this answer, you should try the Jacoco Coverage Gradle Plugin

Just add this in your root project :

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.palantir:jacoco-coverage:0.4.0'      
    }
}

apply plugin: 'com.palantir.jacoco-full-report'

According to the documentation :

The com.palantir.jacoco-full-report plugin adds a task that produces a Jacoco report for the combined code coverage of the tests of all subprojects of the current project.

ToYonos
  • 16,469
  • 2
  • 54
  • 70
  • Thank you, it might be rescue! Should I use it in all projects, subprojects or the root one only? I've tried adding it to root project or subprojects. In the first case it doesn't generate any coverage data, in the second it does the same thing. I was running it as follows: `gradle clean build jacocoFullReport --info`. I also trying to add sonar plugin to root and subprojects - no luck – Dmitry Senkovich Mar 30 '18 at 18:28
  • Apply the full report plugin in the root project, and the regular jacoco one in subprojects – ToYonos Mar 30 '18 at 20:57
  • I've moved `jacocoTestReport` task configuration to the root project and renamed it to `jacocoFullReport`, running it with `gradle clean build jacocoFullReport --info` - and again it generates a report per module:c – Dmitry Senkovich Mar 31 '18 at 12:17