I have a plugin that, when applied, does a bit of work to compute a result that I want to expose to the user of the plugin in the form of a variable. What is the correct way to expose plugin data structures to the user, ideally in a read-only fashion (though read-write is fine if that is easier/more appropriate).
I have found the documentation for how to supply plugins with data: https://docs.gradle.org/current/userguide/custom_plugins.html#sec:getting_input_from_the_build
There are also
extra properties but those appear to be intended as a sort of global state for the project, not really for plugins: https://docs.gradle.org/current/dsl/org.gradle.api.Project.html#org.gradle.api.Project.extraproperties
Finally there is the
Covention Object that sounds like exactly what I need but I have been unable to find any good documentation on how to actually use it: https://docs.gradle.org/current/javadoc/org/gradle/api/plugins/Convention.html
The convention properties added to the project by the plugins. A plugin can add properties and methods to a project through the project’s Convention object. The properties of this scope may be readable or writable, depending on the convention objects.
For reference (in case anyone needs more details about my use case) I want to expose the
versionInfo object to the user after it is filled in on this line: https://github.com/Zoltu/Gradle.Plugin.Versioning/blob/master/src/main/kotlin/com/zoltu/gradle/plugin/GitVersioning.kt#L23