How to convert the following groovy block to kts: ...
# gradle
i
How to convert the following groovy block to kts:
Copy code
mavenDeployer {
       beforeDeployment { MavenDeployment deployment ->
                        if (signing.required)
                            signing.signPom(deployment)
                    }
}
I've heard about the recent improvements about
withGroovyBuilder
, but I can't get how to pass that lambda with the single parameter.
b
The single parameter will be visible as
this
within the lambda
Copy code
mavenDeployer {
   withGroovyBuilder {
       "beforeDeployment" {
           if (signing.required) signing.signPom(this as MavenDeployment)
...
should work
i
Thanks, will try. Probably it's worth adding it to the maven plugin configuration sample as it is the standard incantation required for publishing to maven central.
b
👍
i
Nope, didn't work:
Copy code
[Gradle failure report] Execution failed for task ':kotlin-android-extensions:uploadArchives'.
[Gradle failure report] > Could not publish configuration 'archives'
[Gradle failure report] > org.gradle.kotlin.dsl.GroovyBuilderScopeForRegularObject cannot be cast to org.gradle.api.artifacts.maven.MavenDeployment
b
Hm, I’ll investigate further
It was an oversight in the original design, the Closure
delegate
needs to be exposed => https://github.com/gradle/kotlin-dsl/pull/503