Multi project builds and "singletons" used within a plugin


(steve) #1

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?


(andrew.oberstar) #2

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()

(andrew.oberstar) #3

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

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

(steve) #4

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