The fix is to invoke your plugin before the compilation of the sources. Compilation, as done by maven-compiler-plugin:compile, happens by default in the compile phase of the default lifecycle.
Before that compile phase, the default lifecycle also invokes the generate-sources, which purpose is to:
generate any source code for inclusion in compilation.
Therefore, you should bind your plugin to the phase generate-sources instead of the compile phase. This can either be done using the defaultPhase attribute of your MOJO with
@Mojo(name = "example", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
or declaring it explicitely in the POM in its executions:
<execution> <phase>generate-sources</phase> <!-- id, goal and configuration --> </execution>
You'll need to make sure the classes you generated in that phase are correctly added to the buildpath. If the plugin doesn't do it already (by calling MavenProject.addCompileSourceRoot(directory)), you can make use of the build-helper-maven-plugin:add-source goal to add the directory where the sources have been generated to the buildpath.