How to translate SonarQube Gradle plugin configuration from Groovy to Kotlin DSL

Viewed 13

I have the following configuration in my build.gradle that I would like to convert to Kotlin DSL:

jacocoTestReport {
    reports {
        xml.enabled true
        xml.destination(file("${jacoco.reportsDir}/my-tests/jacocoMyTestReport.xml"))
    }
}

sonarqube {
    properties {
        property "sonar.coverage.jacoco.xmlReportPaths", jacocoTestReport.reports.xml.destination
    }
}

Here is my attempt at converting the sonarqube block, but it fails with

Unresolved reference: reports

sonarqube {
    properties {
        property("sonar.coverage.jacoco.xmlReportPaths", tasks.named<JacocoReport>("jacocoTestReport").reports.xml.destination)
    }
}

What is wrong here? How can I access the jacocoTestReport.reports.xml.destination property using Kotlin?

0 Answers
Related