Multi project builds and "singletons" used within a plugin

I have a plugin from which I would really like to share a singular instance of a helper class across all sub projects. The plugin is applied to separate sub-projects individually.

I tried Project.hasProperty / Project.setProperty but could not figure out how to make that work and I did not see any documentation on them.

Next I tried an old fashioned singleton (using a static member) but I got different instances of the helper.

Help?

If it’s something you’re exposing to the build script author, you could add it via the extension mechanism:

project.extensions.myextension = new MyExtension()

Oh and in the other plugin, you could use a couple ways to access that object again:

project.extensions.getByType(MyExtension)
project.extensions.myextension

Its not something meant for script writers. But I will remember this if there is no other solution. Thanks!