Kotlin / kotlinx-kover

Apache License 2.0
1.25k stars 46 forks source link

combining coverage info from different Gradle projects (automatically) #559

Closed cj1098 closed 1 month ago

cj1098 commented 2 months ago

Hello!

I see on the docs that we can specify other projects reports be merged to a main one via dependencies { kover(project(":another:project")) }

I was wondering if there was a way to iterate through all projects and specify them in this block? I've tried a couple different ways so far but nothing has worked. My app structure is we have a project build.gradle, an app build.gradle (where I'd like everything to be merged to), and a lot of other modules.

I tried adding this block to the app build.gradle but it doesn't seem to combine any reports. It just shows app's coverage.

def projectsWithCoverage = subprojects.findAll {
    ["app", "presentation", "domain", "repositories"].contains(it.name)
}
dependencies {
    subprojects.forEach { sp ->
        if (projectsWithCoverage.contains(sp)) {
            def proj = (sp as String).replace("project ", "")
            kover(project(proj.replace("'", "")))
        }
    }
}

I've seen someone with a block that had something like forEachModuleLayer { kover(project(it)) } but I haven't been able to find anything about that. It's probably some gradle magic I'm not aware of.

shanshin commented 2 months ago

Hi, is something like

def projectsWithCoverage = 
    ["app", "presentation", "domain", "repositories"]

dependencies {
    subprojects.forEach { sp ->
        if (sp.name in projectsWithCoverage) {
            kover(sp)
        }
    }
}

works for you?

shanshin commented 1 month ago

Closed as answered. Feel free to create new issue if you have any additional questions.