Skip to content

Conversation

@jeremylong
Copy link
Contributor

One extension was missed in #473. This PR should complete the transition to the property API.

@jeremylong
Copy link
Contributor Author

Note that this PR also adds the @OutputDirectory to eventually support caching. I've manually tested the output directory changes and things appear to be working correctly.

@chadlwilson
Copy link
Collaborator

I believe there's a much less boilerplatey (and possibly less error-prone) way to make these changes by just defining property fields by their accessor, making them abstract, and then just configuring the convention in constructor

Something like

abstract class AnalyzerExtension {
    @Input @Optional abstract Property<Boolean> getExperimentalEnabled()
    // ...
    
    AnalyzerExtension() {
        experimentalEnabled.convention(false)
        // ...
    }

Like the example at https://docs.gradle.org/current/userguide/lazy_configuration.html#where_to_apply_conventions_from

Which also avoids you needed to create getters and setters, except for any "non-standard" signatures you want to add on.

@jeremylong
Copy link
Contributor Author

For now, I think I'll leave it with all the boilerplate code. To use the method suggested, we would need to convert several classes to interfaces and update more of the implementation.

@jeremylong
Copy link
Contributor Author

Additional manual testing with @chadlwilson PR merged appears to work as expected.

@jeremylong
Copy link
Contributor Author

@chadlwilson I have to take off for a few hours. Unless you object or find something else wrong - I plan on merging this later today (US East Coast time) and releasing 12.1.8.

@chadlwilson
Copy link
Collaborator

chadlwilson commented Oct 13, 2025

For now, I think I'll leave it with all the boilerplate code. To use the method suggested, we would need to convert several classes to interfaces and update more of the implementation.

I think with the magic of Groovy you just need to mark classes as abstract and change some extensions to be created via the extension creation API rather than objects.newInstance or new XXX (so they magically can get passed the relevant project references) but I agree that's not a high priority, and better to seek stability and usage first.

@jeremylong jeremylong merged commit 70582dc into main Oct 13, 2025
3 checks passed
@jeremylong jeremylong deleted the propertyAPI-2 branch October 13, 2025 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants