Kotlin / binary-compatibility-validator

Public API management tool
Apache License 2.0
825 stars 59 forks source link

Klib validation DSL for Groovy is different #214

Closed sandwwraith closed 4 months ago

sandwwraith commented 7 months ago

DSL mentioned in the documentation:

apiValidation {
    @OptIn(kotlinx.validation.ExperimentalBCVApi::class)
    klib {
        enabled = true
    }
}

works for Kotlin, but for some reason, when one wants to use it in Groovy, one should write it slightly differently:

apiValidation {
    klib {
        it.enabled = true
    }
}

It looks like there is no particular reason for DSL having it.enabled = true instead of just enabled = true.

JakeWharton commented 7 months ago

This:

https://github.com/Kotlin/binary-compatibility-validator/blob/3a7003363502236e64bbf044540e569b3eb808a4/src/main/kotlin/ApiValidationExtension.kt#L89

Should use an Action<KlibValidationSettings> which will do the right thing in Groovy and use Kotlin's SAM-with-receiver compiler plugin to do the right thing for Kotlin.