Got it!  Had to reconfigure the sample pom a bit.

On Wed, Apr 27, 2011 at 9:53 PM, Justin Lee <[email protected]> wrote:

> I have a this mojo that generates java source.  I want maven to compile
> that java source but it seems like the java compiler is done before my mojo
> can generate its source.    In the mojo's execute() I've tried making this
> call:          project.getDynamicCompileSourceRoots().add(generatedSrc); and
> i've tried adding to the list given to me via injection
> with ${project.compileSourceRoots}.  I'm not sure which is the correct route
> (my gut says the second) but all this seems to be done longer after javac is
> run anyway.  Any idea how I can get this to run before javac does?
>  Currently the mojo extends CompilerMojo and has an @phase of
> generate-sources.  For completeness, i'll include the source below.
>
>
> /**
>  * Compiles Mirah source files
>  *
>  * @goal generate-sources
>  * @phase generate-sources
>  * @threadSafe
>  * @requiresDependencyResolution compile
>  */
> public class MirahSourcesMojo extends AbstractMirahMojo {
>     /**
>      * Project instance, needed for attaching the buildinfo file. Used to
> add new source directory to the build.
>      *
>      * @parameter default-value="${project}"
>      * @required
>      */
>     private MavenProject project;
>     /**
>      * Project instance, needed for attaching the buildinfo file. Used to
> add new source directory to the build.
>      *
>      * @parameter
> default-value="${project.build.directory}/generated-sources/mirah"
>      * @required
>      * @readonly
>      */
>     private String generatedSrc;
>
>     @Override
>     protected File getGeneratedSourcesDirectory() {
>         return new File(generatedSrc);
>     }
>
>     public void execute() throws MojoExecutionException,
> CompilationFailureException {
>         compileSourceRoots.add(generatedSrc);
>         executeMirahCompiler(generatedSrc, false);
>     }
> }
>
>
>

Reply via email to