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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to