gradle / gradle

Adaptable, fast automation for all
https://gradle.org
Apache License 2.0
16.67k stars 4.66k forks source link

Warn on Boolean properties beginning in 8.x #22218

Open DPUkyle opened 1 year ago

DPUkyle commented 1 year ago

A consequence of GROOVY-10708 is that Tasks or Extensions having an is...() getter returning a Boolean are no longer recognized as properties.

One known example comes from the spring-boot-gradle-plugin. Property o.s.b.g.t.b.DockerSpec#tlsVerify is backed by a primitive boolean field, but the accessor returns a Boolean here. This will fail task validation at build time when we upgrade our bundled Groovy to version 4, as shown below:

    - Error: Type 'org.springframework.boot.gradle.tasks.bundling.DockerSpec' method 'isTlsVerify()' should not be annotated with: @Input, @Optional.   

      Reason: Input/Output annotations are ignored if they are placed on something else than a getter.  

      Possible solutions:   
        1. Remove the annotations.  
        2. Rename the method.

tl;dr

Beginning with Gradle 8.1, we should proactively detect and warn that this pattern will fail in a future version of Gradle where we bundle Groovy 4 - likely Gradle 9.0.

big-guy commented 1 year ago

@gradle/bt-kotlin-dsl-maintainers is this something you could look at?