Kotlin / kotlinx-kover

Apache License 2.0
1.25k stars 46 forks source link

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

Closed nuhkoca closed 1 month ago

nuhkoca commented 2 months ago

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) 
      }
    }
  }
}
shanshin commented 2 months ago

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(",") }) 
            }
        }
    }
}
shanshin commented 1 month ago

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