Does any migration strategy from project.ext to plugin exists?

Hi Community, I need help!

I try to develop a plugin that should replace a set of old gradle scripts that rely on project.ext variables/properties.

I want to implement a step-by-step migration strategy that allows usage of plugin and old scripts at the same time. And I think the first step will be great to replace project.ext variables by well documented, typed, validated scope/closure properties.

Problems with that approach that I found:

  • ext.variable evaluated and available on the earliest stages of configuration. and old script based own if/else logic on those variables. If I try to declare extension properties inside plugin, then I got a situation that plugin configuration closure is not yet parsed… so in two words plugin got own configuration too late, old scripts demand extension property values much earlier.

Possible solution (but I have no idea right now is it possible to implement or not):

  • a plugin is often applied at the begging of the script, so I can declare extension properties in that moment with default values. Maybe I even can make those properties lazy-resolved (provider pattern), so when plugin well parse own configuration I can update values of ext properties with the correct assignments.

what do you think? any suggestions on how to solve that? maybe a small example or link on a relevant solution?


@Gary_Hale can you suggest anything?

Any suggestion? Please advice @etiennestuder @vvaluckas @jkschneider @jonnybbb or please point on someone who may know the answer. Thanks

do we have any community that respond to questions?