I just wrote this wiki page on how to do dependency injection in a plugin:
https://wiki.jenkins-ci.org/display/JENKINS/Dependency+Injection
I want to use this so that I can provide move requests to an external resource to the service class and pass the layout to my publisher during unit tests.
The problem with the example I gave on the wiki is that I cannot easily execute the layout:
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
{
Guice.createInjector(new MyModule()).injectMembers(this);
mySvc.myServiceMethod();
}
I need to delete this line Guice.createInjector ().
Is it possible to mark a subclass of AbstractModule that will be picked up by Guice? I tried marking this with @Exension from the comments here https://issues.jenkins-ci.org/browse/JENKINS-8751 , but it is not introduced.