Kotlin / kotlinx-kover

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could you elaborate more on how to create a Provider in order to lazily provide exclusions?

nuhkoca opened this issue · comments

Hello,

I came across the new migration guide for the version 0.8.0 and Lazy configuration section caught my attention as I use conventional plugins in our project and would like to more about how to create a Provider for exclusions e.g. how to create classProvider for a comma separated string exclusion?

kover {
  reports {
    filters {
      exludes {
         classes(classProvider) 
      }
    }
  }
}

Hi,
according to Gradle's recommendations, you should avoid explicitly creating Provider instance.

if you use convention plugin, then you need to declare the extension in it with property of type Propety<String>, like

interface MyExtension {
    //  comma separated string exclusion
    val exclusions: Property<String>
}

below, when configuring Kover from a comma-separated single string, you need to get Provider of a collection of strings, like

kover {
    reports {
        filters {
            exludes {
                classes(myExtension.exclusions.map { it.split(",") }) 
            }
        }
    }
}

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