Do conventions have a convention?

The user guide talks about convention mapping but gives no details, as far as I can tell. There is a figure 21.6 that says convention object. Where? What part? It is doing what?

I see that there is an interface called Convention that says it is for managing a set of convention objects. How does this relate to the convention mapping mentioned in the user guide? Various plugins in gradle use a class with a name ending in Convention. I don’t see any of them implementing any of the methods. And I see plugins using project.getConvention().getPlugins.put(“somename”, convention) where convention is an instance of the class which has a name ending with Convention. What is that doing?.

Presumably, I can retrieve a convention object associated with a plugin and read properties. What is this doing other than associating a property with a plugin? How is it different from properties or an interface? If there is some convention to be learned from these things, what is that convention?

Convention objects and convention mapping are two different things. Instead of convention objects, you should use extension objects, which are the newer (and public) way to extend Gradle’s object model.

Thanks. I’m not getting the idea though. Is the section in the user guide about conventions likely to disappear?

Do both convention object and extension object simply mean a named object where values can be found that are expected to be used by other plugins? Do either represent a convention that can be discovered programmatically?

Where I see:

project.getConvention().getPlugins().put(“name”, new SomeRandomInterface())

I should substitute:

project.getExtensions()j.create(“name”, new SomeRandomInterface())

The some object is made extensionaware. The ExtensionAware interface has one method which returns an extension container. Am I told that the object is made extensionaware for a reason?

Does it mean anything that a plugin writer needs to know that Convention extends ExtensionContainer? Nothing will expect to find a convention object? I don’t need to know what a convention mapping is?

Convention objects and extension objects are (class-based) ways to extend the Gradle object model. Both can be discovered programmatically.

The user guide talks about conventions in an abstract sense, not necessarily about convention objects.

Only ‘ExtensionAware’ objects can have extensions. Many core Gradle types dynamically implement this interface. Extension objects created with ‘ExtensionContainer.create()’ are also ‘ExtensionAware’.

To learn more about extensions, see [Getting Input from the Build] (http://gradle.org/docs/current/userguide/userguide_single.html#customPluginWithConvention) in the user guide.