To make it even clearer, most things you create through Gradle are decorated. That means you can inject various things into it, and you can save a lot of boilerplate for `Property`s and similar that you should use everywhere, and they are automatically
ExtensionAware
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 boilerplate