You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by cristal <da...@jpmorgan.com> on 2006/05/25 20:23:13 UTC

attach mojo plugin to the build lifecycle

Hi, I had a test mojo plugin which I tried to attach it to the compile phase
of the lifecycle. I did all these following the guide at this link:

http://maven.apache.org/guides/plugin/guide-java-plugin-development.html 

So, I was able to run the command "mvn compile" - I can see the sample
hello:sayhi plugin got executed at compile phase. However, I am wondering if
there is a way to trigger the compile by simply typing "mvn hello:sayhi" so
that one day I can rename the goal from hello:sayhi to "cristal:build" to
have my project compiled, instead of typing "mvn compile".

Basically this is what we had in maven1 but maven2 doesn't seem to do it.

Thanks for any tips on this.

--
View this message in context: http://www.nabble.com/attach+mojo+plugin+to+the+build+lifecycle-t1682566.html#a4563639
Sent from the Maven - Users forum at Nabble.com.


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


Re: attach mojo plugin to the build lifecycle

Posted by cristal <da...@jpmorgan.com>.
Very nice, Edwin.

It works in the way I wanted. This is the answer I've been looking for.

Thanks very much.

--
View this message in context: http://www.nabble.com/attach+mojo+plugin+to+the+build+lifecycle-t1682566.html#a4627843
Sent from the Maven - Users forum at Nabble.com.


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


Re: attach mojo plugin to the build lifecycle

Posted by Edwin Punzalan <ep...@exist.com>.
Running a plugin goal like hello:sayhi can be set to be run after the 
compile phase if you put the plugin annotation:

        @execute phase="compile"

With the annotation, CLI invocation of the goal will always build the 
project up to the compile phase and then run your plugin.

However, you can't put @phase and @execute on the same plugin goal bec 
it would lead to your project being built twice.  You can do what the 
assembly plugin currently does... declare two goals, one is attached to 
a phase (assembly:attached -> @phase) and the other requiring a build 
phase (assembly:assembly -> @execute).

Hope that helps.


^_^


cristal wrote:
> Hi, I had a test mojo plugin which I tried to attach it to the compile phase
> of the lifecycle. I did all these following the guide at this link:
>
> http://maven.apache.org/guides/plugin/guide-java-plugin-development.html 
>
> So, I was able to run the command "mvn compile" - I can see the sample
> hello:sayhi plugin got executed at compile phase. However, I am wondering if
> there is a way to trigger the compile by simply typing "mvn hello:sayhi" so
> that one day I can rename the goal from hello:sayhi to "cristal:build" to
> have my project compiled, instead of typing "mvn compile".
>
> Basically this is what we had in maven1 but maven2 doesn't seem to do it.
>
> Thanks for any tips on this.
>
> --
> View this message in context: http://www.nabble.com/attach+mojo+plugin+to+the+build+lifecycle-t1682566.html#a4563639
> Sent from the Maven - Users forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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: attach mojo plugin to the build lifecycle

Posted by Eric Redmond <er...@gmail.com>.
You're mixing apples and oranges here. "mvn compile" is executing all phases
up to the "compile" build lifecycle phase (which have goals attached to some
of those phases). "mvn hello:sayhi" or "mvn cristal:build" is executing a
specific goal, not a phase.

http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

Eric

On 5/25/06, cristal <da...@jpmorgan.com> wrote:
>
>
> Hi, I had a test mojo plugin which I tried to attach it to the compile
> phase
> of the lifecycle. I did all these following the guide at this link:
>
> http://maven.apache.org/guides/plugin/guide-java-plugin-development.html
>
> So, I was able to run the command "mvn compile" - I can see the sample
> hello:sayhi plugin got executed at compile phase. However, I am wondering
> if
> there is a way to trigger the compile by simply typing "mvn hello:sayhi"
> so
> that one day I can rename the goal from hello:sayhi to "cristal:build" to
> have my project compiled, instead of typing "mvn compile".
>
> Basically this is what we had in maven1 but maven2 doesn't seem to do it.
>
> Thanks for any tips on this.
>
> --
> View this message in context:
> http://www.nabble.com/attach+mojo+plugin+to+the+build+lifecycle-t1682566.html#a4563639
> Sent from the Maven - Users forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>