Missing a flavor coverage on multi flavor android project

Hi, I’m facing a problem running Jacoco + sonar on my android project, I have two flavors and when I run the coverage just one is showing in sonar.

This is my sonar script

    apply plugin: "org.sonarqube"

    sonarqube {
        properties {
            property "sonar.host.url", ""
            property "sonar.login", ""
            property "sonar.java.coveragePlugin", "jacoco"
            property "sonar.projectKey", "storekeeper"
            property "sonar.sourceEncoding", "UTF-8"
            property "sonar.log.level", "DEBUG"
            property "sonar.verbose", "true"
            property "sonar.sources", "src/main,src/courier"
            property "sonar.tests", "src/test/java,src/testCourier/java"
            property "sonar.java.binaries", "$projectDir.path/build/intermediates/javac/debug/classes"
            property "detekt.sonar.kotlin.config.path", "$project.rootDir/config/detekt/detekt.yml"
        }
    }

jacoco script

    apply plugin: 'jacoco'

    jacoco {
        toolVersion = "0.8.7"
    }

    tasks.withType(Test) {
        jacoco.includeNoLocationClasses = true
        jacoco.excludes = ['jdk.internal.*']
    }

    def testTask= ['test']

    task coverageReport(type: JacocoReport, dependsOn: testTask) {
        reports {
            xml.enabled true
        }
        // Change as needed
        def fileFilter = [
                '**/binding/**/*.*',
                '**/databinding/**/*.*',
                '**/*Test*.*',
                'android/**/*.*',
                '**/di/**/*.*',
                '**/BR.*',
                '**/R.*',
                '**/R$*.*',
                '**/BuildConfig.*',
                '**/Manifest*.*',
                '**/*$Lambda$*.class',
                '**/*_MembersInjector.class',
                '**/Dagger*Component*.class',
                '**/Dagger*Subcomponent*.class',
                '**/*Subcomponent$Builder.class',
                '**/*Module_*Factory.class',
                '**/*_Factory.*',
                '**/*_Impl*.*',
                '**/*Activity.*',
                '**/*Activity$*',
                '**/*Fragment.*',
                '**/*Fragment$*',
                '**/*View.*',
                '**/*View$*',
                '**/views/**/*.*',
                '**/*ViewPager*.*',
                '**/*ViewHolder*.*',
                '**/*Decorator*.*',
                '**/*DataBinderMapperImpl*.*',
                'dyscan/**',
                'libs/**',
        ]

        def debugTree = fileTree(
                dir: "$buildDir/tmp/kotlin-classes/debug",
                excludes: fileFilter
        )

        def mainSrc = "$projectDir/src/main/java"

        def coverageSourceDirs = [
                "$project.rootDir/app/src/courier/java",
                "$project.rootDir/app/src/shopper/java",
                "$project.rootDir/app/src/main/java",
        ]
        additionalSourceDirs.setFrom(files(coverageSourceDirs))
        sourceDirectories.from = files([coverageSourceDirs])
        classDirectories.from = files([debugTree])
        executionData.from = fileTree(
                dir: project.buildDir,
                includes: ['**/*.exec', '**/*.ec']
        )
    }

this is in the root gradle

    subprojects {
        afterEvaluate { subproject ->

            subproject.apply from: "$subproject.rootDir/gradleScripts/script-jacoco-report.gradle"

            sonarqube {
                properties {
                    property "sonar.coverage.jacoco.xmlReportPaths", "$buildDir/reports/jacoco/coverageReport/coverageReport.xml"
                }

            }
            rootProject.tasks['sonarqube'].dependsOn("${subproject.path}:coverageReport")
        }
    }

thank you!!

Thank you for reporting @Esteban_Quintero !

To help us understand the issue better, could you please explain what you mean by ‘flavor’?

Hi sure, flavor is a variant code on my app, we have two variants in a different folders with tests also, but we only see on sonar the coverage of one of those.

Android Flavors justing case!

thank you!!

Hi chrislain could you please help me with this :pray: !!!

thanks.

Hello Esteban,

Would you be able to send me the logs? If so, send them privately, please.

Thank you.
-Chrislain