Hi, Is there any way on using dependency injection with gradle custom plugins? I’m writing a bunch of plugins and I’m interested in using dependency injection for e.g. better testability.
We are currently working on this. Dependency injection is already available for internal Gradle services, but I’m guess you are wanting to inject your own collaborators. Our dependency injection will support this at some point.
In the meantime, the solution has been to use package-protected setters and inject doubles at test time. Not ideal we know, but things will improve.
Hi Luke, Thanks for prompt response. Could You please tell which dependency injection framework You use (e.g. Google Guice)? Also I’d like to know when (in which release or version) DI will be available for plugins developers?
Could You please tell which dependency injection framework You use (e.g. Google Guice)?
It’s custom, based on JSR 330.
Also I’d like to know when (in which release or version) DI will be available for plugins developers?
It’s undetermined at this stage.
Keeping plugin code close to 330 should make it easy to migrate after.
Thanks Luke for the answer!
Is there a better way to do dependency injection in plugins with Gradle 2.x? Is there an example someone can point me to?