I am developing a maven plugin and to make it more testable I would like to use a light-weight dependency injection framework(like Guice) to manage services etc but while I can get them to integrate with applications I haven't been able to get them integrated with my plugin. Is there any way to do this save for doing the dependency-injection in a static fashion?
Maven already provides you with embedded IoC container called Plexus. You can include other components
public class MonitorMojo
extends AbstractMojo
{
/**
* The website monitor component instance that will be injected
* by the Plexus runtime.
* @component
*/
private WebsiteMonitor monitor;
public void execute()
throws MojoExecutionException, MojoFailureException
{
// TODO Auto-generated method stub
}
}
and refer to properties
@Parameter( property = "sayhi.greeting", defaultValue = "Hello World!" )
private String greeting;
You can find more information on maven plugin dev site and plexus documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With