Is there difference between Convention and Extension objects?


(martin9002) #1

Hi,

I was wondering, if there’s some simple explanation of difference between concept of Convention objects and Extension objects? i.e.: project.extensions.create vs. project.convention.plugins

Thanks


(Luke Daley) #2

You should use extensions, as convention plugins might go away at some point.

The primary difference is that extensions effectively add a new property to an object (i.e. an extension). Convention plugins get mixed in to the target object, so all of it’s methods and properties become available on the target.

Convention plugins may seem better at first glance, but in practice they are problematic. Because extensions are like properties, it’s far more obvious when they are being used as opposed to just “magic” methods.

I strongly recommend using extensions.


(martin9002) #3

Thank you for clearing that out. I’ve been looking into some of existing plugins, and I noticed that these two gets often mixed together. It was not clear to me from documentation, how exactly they differ.