Reputation: 486
I’m new to maven. I’m trying to integrate a plugin into my build so that it would execute automatically as part of phase execution.
Say I want to plug into clean lifecycle phase.
The mojo I’m using was annotated specifying that it should be injected into clean phase:
/**
*
* @goal clean
* @phase clean
* @requiresProject
*/
public class CleanMojo extends AbstractSCAMojo {
This mojo was installed following instructions in Using Plugin Tools Java5 Annotations. I added plugin to my pom.xml:
<build>
<plugins>
<plugin>
<groupId>myclean.plugin</groupId>
<artifactId>myclean-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<logfile>C:/temp/clean.log</logfile>
</configuration>
</plugin>
</plugins>
</build>
In my understanding having lifecycle binding in Mojo java code eliminates the need to provide executions in build-plugins-plugin. Is that correct?
I was expecting that after invoking mvn clean configured above myclean.plugin:myclean-maven-plugin will be executed as part of the clean goal, but nothing happens besides regular maven clean procedure.
When pom is changed to specify executions
myclean.plugin:myclean-maven-plugin is invoked so I’m certain mojo code doesn’t contain blocking errors – this is just a question of configuration.
There is probably something more I need to specify to make plugin executed automatically (i.e. without specifying executions
), but what?
Upvotes: 1
Views: 675
Reputation: 52645
As per the documentation, you should be adding the following annotation before the class definition:
@Mojo(name = "clean", defaultPhase = LifecyclePhase.clean)
@goal
and @phase
are for javadocs.
Upvotes: 1