You are creating a custom maven plugin, everything works but when it comes to using it in a maven module inside Eclipse, m2eclipse plugin cries with message – “plugin execution not covered by lifecycle configuration”.
Now one could find a lot of documentation on how to get around with this error while using a third-party plugin, but what about if you yourself are creating a maven plugin. You would like to fix it before it comes in front of your custom-plugin users.
I was very confused with the existing documentation on how to fix it. So now as finally I fixed it, let me share it with you and come to the point.
One needs to have “src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml” file inside custom maven plugin. This file determines the action of your plugin with respect to Eclipse activities.
If you want to tell m2e to silently ignore the plugin execution with respect to any Eclipse activities, here’s what you may want to add in this file.
[xml]
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<goals>
<goal>some-goal</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
[/xml]
If you want your plugin to execute at the time of partial or full Eclipse build, you will have following configuration:
[xml]
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<goals>
<goal>some-goal</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>see below</runOnIncremental>
<runOnConfiguration>see below</runOnConfiguration>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
[/xml]
If <runOnIncremental/> is set to true (the default), corresponding mojo will be executed during both full and incremental workspace builds. If set to false, the mojo will be executed during full workspace build only.
If <runOnConfiguration/> set to true, corresponding maven mojos will be executed as part of project import and configuration update.
Leave a Reply