You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by noah <ia...@gmail.com> on 2007/06/20 15:37:23 UTC

Plugin to compile and run

I'm currently using ant-run in the generate-sources phase to compile a
class and then execute it.  It works fine, but I need it on several
projects and it's a pain to replicate the build file for each one, so
I'd like to write a plugin to do it.

Is there some way I can invoke the compile plugin on a particular file
(or set of files) from a custom plugin? Or convert a build file (using
the maven classpaths) to a plugin?

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


Re: Plugin to compile and run

Posted by noah <ia...@gmail.com>.
On 6/20/07, Jo Vandermeeren <Jo...@ordina.be> wrote:
> Hi Noah,
>
> Why don't you package that "generator" class with your plugin?
> Then define an execution for it during the generate-sources phase.

Ah right, because the class to compile is project specific.  The
classes to generate are described as code and we do a little bit of
reflection as well.

>
> You should not call plugins from other plugins, because it makes your plugin
> hard to reuse.

I would normally agree, but considering that it's the compiler plugin,
it will most certainly always be present, yes?  I don't really care if
it's the compiler plugin, I just need to invoke javac on a file.

> Instead, extend the lifecycle by plugging in on certain phases.
> Cf. http://www.mail-archive.com/users@maven.apache.org/msg67531.html
>

I could probably make this work, but it would be nice if all my users
didn't have to do the same. Right now it's only 2 plugins, but I
anticipate needing 3 or more in the future. That's a maintenance and
upgrade nightmare.

> Cheers
> Jo
>
> On 6/20/07, noah <ia...@gmail.com> wrote:
> >
> > I'm currently using ant-run in the generate-sources phase to compile a
> > class and then execute it.  It works fine, but I need it on several
> > projects and it's a pain to replicate the build file for each one, so
> > I'd like to write a plugin to do it.
> >
> > Is there some way I can invoke the compile plugin on a particular file
> > (or set of files) from a custom plugin? Or convert a build file (using
> > the maven classpaths) to a plugin?
> >
> > ---------------------------------------------------------------------
> > 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: Plugin to compile and run

Posted by Jo Vandermeeren <Jo...@ordina.be>.
Hi Noah,

Why don't you package that "generator" class with your plugin?
Then define an execution for it during the generate-sources phase.

You should not call plugins from other plugins, because it makes your plugin
hard to reuse.
Instead, extend the lifecycle by plugging in on certain phases.
Cf. http://www.mail-archive.com/users@maven.apache.org/msg67531.html

Cheers
Jo

On 6/20/07, noah <ia...@gmail.com> wrote:
>
> I'm currently using ant-run in the generate-sources phase to compile a
> class and then execute it.  It works fine, but I need it on several
> projects and it's a pain to replicate the build file for each one, so
> I'd like to write a plugin to do it.
>
> Is there some way I can invoke the compile plugin on a particular file
> (or set of files) from a custom plugin? Or convert a build file (using
> the maven classpaths) to a plugin?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>