This basically extends this question to Kotlin DSL instead of Groovy DSL:
How does the Groovy DSL solution of
if (hasProperty('buildScan')) {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
}
translate to Kotlin DSL?
The problem I'm running is that the "buildScan" extension or the com.gradle.scan.plugin.BuildScanExtension
class cannot statically be used as they are either present or not present depending on whether the --scan
command line argument was provided to Gradle or not.
I've tried
if (hasProperty("buildScan")) {
extensions.configure("buildScan") {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
}
}
but as expected termsOfServiceUrl
and termsOfServiceAgree
do not resolve, however I'm clueless what syntax to use here.