I’m building a plugin that requires a reasonably-deeply-nested set of properties, which I’m trying to achieve using the extension container mechanism. So I’ve got a handful of extension classes, and I add them to the plugin like so:
A a = project.extensions.create(‘a’, A) B b = project.a.extensions.create(‘b’, B) C c = b.extensions.create(‘c’, C) …
where class A contains a B, and class B contains a C, and so on. Creating these seems to work ok.
My questions are:
Is this the appropriate way to do deep property hierarchies for plugins? I haven’t had much luck finding many exampls that try to nest more than one extension. and which aren’t using the older ‘conventions’.
What is the lifecycle of these extensions? i.e. what is the relative ordering of each extension’s construction, and how/when does each child extension get set on its parent (am I expected to inject these myself, or does Gradle do it for me?)? At what point does the configuration block from the build file get applied to each extension, and in what order are the properties applied? (i.e. do child extensions get initialized before parent ones?)
Any pointers to good examples would also be great.