i've a maven plugin composed of some mojos. Suppose there is myproject.FirstMojo declared as @goal first and myproject.SecondMojo declared as @goal second
what I want to do is inject first mojo as property of second mojo. What I've tried is declare it the following way :
/**
* @component role="myproject.FirstMojo"
*/
private FirstMojo first;
Unfortunatly, when doing so, I get a Component descriptor cannot be found in the component repository:
error.
What should I do ?
You can use:
/** @component role="org.apache.maven.plugin.Mojo" role-hint="groupId:artifactId:version:second" */
private FirstMojo first;
Note that they have to be in the same plugin, and you must replace the group, artifact and version with your values. This will likely involve filtering your source code for the correct version, which makes it a bit complicated.
I would highly recommend factoring out the functionality you need into a separate class (perhaps a Plexus component if you need access to some components in there), or an abstract base class.
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