我的 build.gradle
中有以下配置,我想将其转换为 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
}
}
这是我尝试转换 sonarqube
block ,但失败了
Unresolved reference: reports
sonarqube {
properties {
property("sonar.coverage.jacoco.xmlReportPaths", tasks.named<JacocoReport>("jacocoTestReport").reports.xml.destination)
}
}
这里出了什么问题?如何使用 Kotlin 访问 jacocoTestReport.reports.xml.destination
属性?
最佳答案
请尝试类似的操作:
tasks {
sonarqube {
val path = jacocoTestReport.get().reports.xml.outputLocation.get()
properties {
property("sonar.coverage.jacoco.xmlReportPaths", path)
}
}
withType<org.sonarqube.gradle.SonarTask>().configureEach {
dependsOn(test, jacocoTestReport)
}
}
这对我有用
关于sonarqube-scan - 如何将 SonarQube Gradle 插件配置从 Groovy 转换为 Kotlin DSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73452889/