My opinion is that the conventions should be set by the plugin after creating the extension. I think it works well as a best practice for maximizing the re-usability of the extension class. For example, some time in the future you make another variant of the plugin that uses the same extension class but with different conventions. I also believe it is best to try and contain these types of “business logic” in the plugin class instead of distributing it across the entity classes (extension classes, task classes, etc).
So, I would do the following in the plugin’s apply()
:
TestExtension te = project.extensions.create("testExt", TestExtension.class);
te.getFoo().convention(2);