Kotlin / kotlinx-kover

Apache License 2.0
1.25k stars 46 forks source link

Pass list of projects via all projects filter #575

Closed igorromcy closed 1 month ago

igorromcy commented 1 month ago

I'm trying to use all projects with a filter

allProjects(filter: Spec<Project>)

but I didn't understand via the documentation how I should achieve that, so far I have a list of strings with all projects (i.e: ":feature:login", ":feature:signup", etc..)

shanshin commented 1 month ago

Hi, to merge all projects you shouldn't specify filter, like this

            kover {
                merge {
                    // merge with all projects
                    allProjects()

                   // other configs
                }
            }
igorromcy commented 1 month ago

sorry I wasn't clear, I need to use that filter, so I'm trying to convert the list of strings (modules) to that Spec

I just found out that we have projects(vararg projectNameOrPath: String) available to use as a filter as well, let me try that.

shanshin commented 1 month ago

Yes, projects(...) is intended for cases when there is only a list with the names of projects that should be merged.

But you can also use allProjects if you specify a predicate in the form of a lambda expression:

kover {
    merge {
        allProjects {
            it.path in setOf(":feature:login", ":feature:signup") // or for Groovy  [":feature:login", ":feature:signup"]
        }
    }
}
igorromcy commented 1 month ago

Perfect! Thank you