You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Magne Rasmussen <Ma...@invenia.no> on 2006/12/18 09:19:40 UTC

Running compile from within another mojo

Hi.
 
I have an plugin which processes the class files generated by compile,
generates a new java file based on the class files, and then needs to
compile this generated java file.
 
The question is: Can I get hold of, and run, the compile mojo from
within my plugin? If so, how do I do that?
 
Magne Rasmussen

Re: Running compile from within another mojo

Posted by Ian Petzer <ia...@gmail.com>.
Hi,

I've been looking at doing something similar. I want to call another
MOJO  from within my MOJO.

There is entry in the mailing archives. See
(http://mail-archives.apache.org/mod_mbox/maven-dev/200511.mbox/%3Cc38ad92d0511161552k24920759s2ed19b2d807a20f5@mail.gmail.com%3E)

A suggestion is made to run a plugin by invoking maven again through a
command line interface. (This is how it is done in the
maven-release-plugin)

So then you could:
1) Invoke your MOJO
2) Use the command line to run compile
3) Do your stuff
3) User the command line to run compile again

Cheers,
Ian

On 18/12/06, Kenney Westerhof <ke...@apache.org> wrote:
>
>
> Magne Rasmussen wrote:
> > Hi.
> >
> > I have an plugin which processes the class files generated by compile,
> > generates a new java file based on the class files, and then needs to
> > compile this generated java file.
> >
> > The question is: Can I get hold of, and run, the compile mojo from
> > within my plugin? If so, how do I do that?
> >
>
> No, you can't.
> You should split this up into 2 projects - one that produces the first class files,
> and a second project that generates code from the class files of the first project.
>
> There might be a workaround though, but it's not recommended: process the classes
> in the process-classes phase, generating the source files.
>
> Then configure the compiler plugin to also run in the process-classes phase to compile
> the newly generated sources. It might not run in the correct order, though.
> I really recommend splitting up into 2 projects.
>
> -- kenney
>
>
> > Magne Rasmussen
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Running compile from within another mojo

Posted by Kenney Westerhof <ke...@apache.org>.

Magne Rasmussen wrote:
> Hi.
>  
> I have an plugin which processes the class files generated by compile,
> generates a new java file based on the class files, and then needs to
> compile this generated java file.
>  
> The question is: Can I get hold of, and run, the compile mojo from
> within my plugin? If so, how do I do that?
>  

No, you can't.
You should split this up into 2 projects - one that produces the first class files,
and a second project that generates code from the class files of the first project.

There might be a workaround though, but it's not recommended: process the classes
in the process-classes phase, generating the source files.

Then configure the compiler plugin to also run in the process-classes phase to compile
the newly generated sources. It might not run in the correct order, though.
I really recommend splitting up into 2 projects.

-- kenney


> Magne Rasmussen
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org