Determining Maven execution phase within a plugin?

Thus, within the plugin, I would need to know if I'm executing process-classes (...) or if I'm executing process-test-classes AFAIK, this is not really possible. I could, of course, create two plugins for this, but this kind of solution deeply offends my sensibilities and is probably against the law in several states. I don't see anything wrong with having two Mojos sharing code but bound to different phases.

Something like the Maven Compiler Plugin (and its compiler:compile and compiler:testCompile goals).

Well, that answer by Dr. J is pretty definitive. I must say that seems pretty darn weird, but what evs... Thanks for the speedy answer. – Hellblazer Sep 20 '10 at 0:28 I also discovered that the AspectJ compiler Maven plugin does the same thing as what I need to do and so I'm going to see how they dealt with this.

– Hellblazer Sep 20 '10 at 1:06 So, the pattern the AspectJ compiler used works for me. For posterity, I simply create two Mojos in my plugin, one for process-classes and one for process-test-classes. This solution doesn't require another plugin (which was my main fear).

– Hellblazer Sep 20 '10 at 2:53 Can't you get from the MavenExecutionRequest? Of course I ask about how to get that object. – Thomas Sep 20 '10 at 3:04 1 Yup, in almost all Maven Plugins I implemented there was an AbstractXyzMojo, a CompileXyzMojo and a TestCompileXyzMojo.

I guess that's standard for Maven Plugin development (+1) – Sean Patrick Floyd Sep 20 '10 at 11:27.

You can't get the phase, but you can get the execution ID which you have as separate. In the plugin: /** * @parameter expression="${mojoExecution}" */ private org.apache.maven.plugin. MojoExecution execution; ... public void execute() throws MojoExecutionException { ... System.out.

Println( "executionId is: " + execution.getExecutionId() ); } I'm not sure if this is portable to Maven 3 yet.

Thanks. I just used the pattern that AspectJ uses and it works perfectly fine. Don't want to go against the grain when Maven wants a particular pattern to be used.

– Hellblazer Sep 21 '10 at 21:14 yes, that's definitely a better way to handle it – Brett Porter Sep 23 '10 at 5:35.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions