Arjan van Wieringen
01/27/2024, 7:49 AMouterExtension.extensions.create
but logically the extensions
does not resolve.
2. I don't fully understand why I need ObjectFactory. Is this related to lazy instantiation of element, or something else? I fail to see why I can't just instantiate some data classes where needed.ephemient
01/27/2024, 7:56 AMobjects.newInstance
) the actual value will be a ExtensionAware
ephemient
01/27/2024, 7:57 AMObjectFactory
, in addition to decoration, also allows Gradle to @Inject
Arjan van Wieringen
01/27/2024, 8:01 AMVampire
01/27/2024, 12:24 PMExtensionAware
like also most built-in DSL objects are even if they don't declare it. You can also just declare that you type extends / implements ExtensionAware
and Gradle cares about the rest. If you do not, you can anytime just cast it, but I'd just always declare it explicitly. For extensions on extensions and so on, you also get nice type-safe accessors for Kotlin DSL automatically and so on.
You can just use a data class and use add
on ExtensionAware
, but you really shouldn't imho, but always let Gradle decorate things and declare the ExtensionAware
, and especially use Property
and alike everywhere anyway. As long as you're not needing any functions on the extension it can even be an interface and Gradle does the remaining boilerplateephemient
01/27/2024, 12:46 PMdata class
because they're finalVampire
01/27/2024, 12:51 PMadd
? Why shouldn't you? You can create anything you like and register it as extension, even a Boolean
. You just shouldn't, as you then cannot lazily wire things togetherephemient
01/27/2024, 12:51 PMVampire
01/27/2024, 1:35 PMadd
Vampire
01/27/2024, 1:35 PM