If I have a bunch of `ValueSources` that do expens...
# plugin-development
j
If I have a bunch of
ValueSources
that do expensive things (like execute git, etc), and I want to share these across multiple plugins so that I don't have to duplicate code, as well as create multiple providers for the same thing, I had an idea to put them in a BuildService. however, it seems like if I create the providers in order to pass them to the service via params, then they get run, even if the build service method that returns that provider never is called. I had an idea to create the providers only when they are accessed via build service, but to do that, id need a reference to ProviderFactory as a param, but I don't think that is serializable (for CC). is there an established pattern here?
Can i inject a ProviderFactory into a BuildService?
yes I can.
p
A ValueSource is scoped to the Build, not to a Project, so the inputs should only produce 1 outcome that will be reused/cached during CC. Edit: it is not cached across projects 🤔 A BuildService provides inputs during execution time for multiple tasks.
Ah, I read this issue a few days ago https://github.com/gradle/gradle/issues/38324
👀 1