Is it possible to inject a Plexus component into a Mojo.
Here's what I tried but myComponent is always null.
My Component:
import org.codehaus.plexus.component.annotations.Component;
@Component(role = MyComponent.class, hint = "mine")
public class MyComponent {
}
My Mojo:
import org.codehaus.plexus.component.annotations.Requirement;
import org.apache.maven.plugins.annotations.Component;
public class MyMojo extends AbstractMojo {
@Requirement(role = MyComponent.class, hint = "mine", optional = false)
protected MyComponent myComponent;
@Component
protected MavenProject project;
}
You Java part is correct, but you need to add some sources processing to build of your Maven plugin. This can be achieved by adding the following to your
buildinpom.xml: