Search code examples
kotlingradle-pluginkover

How to call kover DependencyHandler extension from a Gradle custom plugin?


I'm building a custom Gradle plugin to apply Kover plugin to multiple projects. To generate a Kover report from multiple subprojects, I need to add a dependency to the root project, according to the docs:

dependencies {
  kover(project(":another:project"))
}

I'm trying to access that kover extension in my custom Gradle plugin but I can't find a way to make it work. Can you please let me know how to define that dependency in my Gradle Plugin.apply() method?

I tried following this solution, but I can't find the extension kover to import in my Gradle code.


Solution

  • I found the solution:

    val configurations: Configuration = project.configurations.getByName(KoverNames.DEPENDENCY_CONFIGURATION_NAME)
    configurations.dependencies.add(project.dependencies.create(project.project("my-subproject")))