mavenmaven-plugin

Guice Dependency Injection Not Working in Maven plugin


I am using the sisu-maven-plugin to generate a configuration file for a maven plugin I am writing. I checked the javax.inject.Named file it creates in the META-INF folder of my maven plugin's jar, and this file has all the classes I have annotated with the @Named and @Singleton (both annotations on each component) listed in it. Those classes are the only thing listed in the config file. I then have a single constructor annotated in my mojo with the @Inject annotation. When I try to use my plugin in a small test app, I get a guice error saying "Could not find suitable constructor".

I tried downloading the example plugin provided at http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-5382/ but I received the same error. So my question is this: has anyone successfully gotten guice dependency injection working in a maven plugin? If so, what did you have to do?

Also, I am using maven 3.0.3.


Solution

  • I switched to maven 3.2.1, and the dependency injection worked as expected.