Kotlin / kotlinx-kover

Apache License 2.0
1.37k stars 53 forks source link

afterEvaluate task with name 'koverHtmlReportDebug' not found in project #524

Closed bakjoul closed 10 months ago

bakjoul commented 10 months ago

Hello,

On version, 0.7.0, i used to do this to automatically open the generated report :

afterEvaluate {
    android.applicationVariants.configureEach { variant ->
        def variantName = variant.name.capitalize()
        def htmlOutDir = file("$buildDir/reports/kover/html${variantName}")

        tasks.named("koverHtmlReport${variantName}").configure {
            doLast {
                openReport htmlOutDir
            }
        }
    }
}

It also works on 0.7.1, but from 0.7.2, it doesn't work anymore. I get the following error (and i don't get why) :

Caused by: org.gradle.api.UnknownTaskException: Task with name 'koverHtmlReportDebug' not found in project ':app'.

shanshin commented 10 months ago

Hi, try to rewrite this code

        tasks.named("koverHtmlReport${variantName}").configure {
            doLast {
                openReport htmlOutDir
            }
        }

like this

        tasks.matching { it.name == "koverHtmlReport${variantName}"}.configureEach {
            doLast {
                openReport htmlOutDir
            }
        }
bakjoul commented 10 months ago

Hi, try to rewrite this code

        tasks.named("koverHtmlReport${variantName}").configure {
            doLast {
                openReport htmlOutDir
            }
        }

like this

        tasks.matching { it.name == "koverHtmlReport${variantName}"}.configureEach {
            doLast {
                openReport htmlOutDir
            }
        }

Your solution works. Thank you very much !