Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share data between Mojo through Maven plugin execution

I am working on a Maven plugin, composed of 3 mojos inheriting AbstractMojo.

Long story short, these 3 mojos are used to :

  1. compile some groovy scripts
  2. generate SQL scripts with data extracted from compilation
  3. load these scripts to a database

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 ?

like image 977
Alexandre Bourdin Avatar asked Jan 14 '14 13:01

Alexandre Bourdin


1 Answers

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.

like image 147
Alexandre Bourdin Avatar answered Oct 13 '22 11:10

Alexandre Bourdin