Sharing data between Mojo and Maven

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

In short, these 3 mojo are used for:

  • compile groovy scripts
  • generate SQL scripts with data extracted from compilation
  • upload these scripts to the database

Earlier, my second mojo inherited the first, and the third inherited the second, and they were all called super.execute()in their method execute()so that they could cascade from each other.

I am rewriting the plugin to make it cleaner and improved, so I removed the inheritance and want to rely on Maven's own life cycle, linking phases 3 of mojos to compile, packageand deploy.

The problem I am facing is that I cannot figure out which way to transfer the second mojo data that I retrieve during the first mojo run (for example, file extensions, if the file is compiled correctly, the package path, etc. ) Is there a temporary storage or caching system available in the Maven plugin API?

+4
source share
1 answer

Since there is no easy way to exchange data between Maven mojos, I decided to write the data that I need to transfer to the next Mojo in a CSV file (XML, YAML or any other format could also do the job).

, , , , .

+3

All Articles