The same instance of CompileState is being passed to every GMaven mojo. During the build, the CompileState singleton is being loaded with files to compile when stubs are generated, then cleared when the Compile occurs.
The problem with this is that GenerateStubs can happen irrespective of Compile.
My issue occurs because I am using the maven-source-plugin, which causes GenerateStubs to be run out of turn, after Compile. The next project to be compiled in the <module/> build gets the resulting "forced-compile" files from the previous build. And because some dependencies aren't there in the next build in the chain, the compilation fails.
In my case, GMaven is trying to compile a custom Maven Mojo class into another project, and that project does not reference the Maven dependencies.
I am not sure the best way to fix this. If the CompileState class used the current MavenProject as a key, that would work (since a single project will have the same forced-compile files throughout the build). I suppose the MavenProject could be passed in as an argument. I'm not totally up on Plexus, so there might be a way to discover the current project info during the build...
The issue seems to me, from hacking into the source, that there is an assumption that GenerateStubs will always be followed by Compile, in order, for each project. While this is usually the case, it appears that it is not necessarily always the case.
This is a subtle yet important bug, as it can result in classes being compiled into the wrong projects without warning (if all the dependencies happen to line up).