I am working on a Maven compiler plug-in for a new programming language. Like with other Maven compiler plug-ins, this plug-in is invoked in different phases of a module build (e.g., compile
, test-compile
), and for multiple modules during a reactor build. The language has a "bootstrap" component that stores certain static information which includes Class
and ClassLoader
objects. The information stored in this bootstrap component is not reusable across multiple executions of the compiler plug-in (it needs to be freshly generated each time). Currently, compilation fails because invalid information from an earlier execution is picked up (e.g., the test-compile
execution might use some information left over from the earlier compile
phase).
I realize that there are a number of different ways to solve such an issue (e.g., handle the currently static information in a different way, or provide some way of wiping it out between phases, etc.). My question here is primarily about Maven-specific ways to address this sort of problem.
The default instantiation strategy already creates a new plug-in instance every time, but that doesn't help in my case since the static data is not in the Maven plug-in itself, but in the compiler library that it depends on (come to think of it, I don't think it would help with static data either way). Another option would be to start a separate JVM for each execution, similar to the <fork>
option of the Maven Compiler Plugin, but it appears that this existing mechanism is not easily reusable and would have to be essentially re-created from scratch.
Is there a Maven mechanism to isolate data (and loaded classes) between different executions of the same plug-in?