Kotlin / kotlinx-kover

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

combining coverage info from different Gradle projects (automatically)

cj1098 opened this issue · comments

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.

Hi,
is something like

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

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

works for you?

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