SonarQube Kotlin DSL

Versions:
SonarQube 7.9.1-Community
sonarqube-gradle-plugin:3.0

Hi everybody, I’m trying to setup JaCoCo & Sonarqube in an Android multi-module project, the project uses Kotlin Gradle DSL instead of the old Groovy. Due to that I’m facing a problem to setup the xmlReportPaths because I couldn’t find how to do this using Kotlin DSL

If I change my build.gradle to use Groovy and setup like the following it works and shows the coverage:

sonarqube {
  properties {
      property "sonar.coverage.jacoco.xmlReportPaths", 
                     "$buildDir/reports/jacoco/coverageReport/coverageReport.xml"
      }
}

What I’ve tried so far but didn’t work:

        delegateClosureOf<org.sonarqube.gradle.SonarQubeExtension> {
        properties {
            property("sonar.coverage.jacoco.xmlReportPaths", "$buildDir/reports/jacoco/coverageReport/coverageReport.xml")
        }
    }

and also:

`closureOf<org.sonarqube.gradle.SonarQubeExtension> {
        properties {
            property("sonar.coverage.jacoco.xmlReportPaths", "$buildDir/reports/jacoco/coverageReport/coverageReport.xml")
        }
    }`

If you’re using the plugins {} method to apply the plugin, your Groovy version should work almost as-is. You just need to add the parenthesis to the property(...) method call.