Dependency Injection in Custom Plugin


I was looking for samples and documentation of using dependency injection in a custom plugin. All the related links in the similar topics don’t point to anything conclusive.

I am familiar with dagger2 and am fine with injecting when the plugins apply method is called but I am worried that the graph won’t be around for tasks at execution time.

I was thinking along the lines of

override fun apply(target: Project) {

Will the object graph stay in memory or will each task need to do the same for dependencies?

fun execute() {

Any documentation would be appreciated.