I am working on a Maven plugin, composed of 3 mojos inheriting AbstractMojo
.
Long story short, these 3 mojos are used to :
Previously, my 2nd mojo inherited the 1st, and the 3rd inherited the 2nd, and they all called super.execute()
in their execute()
method, so that they could cascade from each other.
I am rewriting the plugin in order to make it cleaner and better designed, thus I removed inheritance and want to rely on Maven native lifecycle, binding the 3 mojos to compile
, package
and deploy
phases.
The issue I am facing is that I can't figure out a clean way to pass to the 2nd mojo the data I extract during the 1st mojo's execution (like file extensions, if the file is correctly compiled, package path, etc). Is there any temporary storage or caching system available in the Maven plugin API ?
As there is no straightforward way to share data between Maven mojos, I chose to write data I need to pass to the next Mojo in a CSV file (XML, YAML or any other format could have done the job as well).
The advantage over using some caching or context stored in memory through execution is that you can execute one goal, keep its result in filesystem, and then execute the following goals any time later.
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