I'm using a maven plugin that defines a custom packaging type and lifecycle for my projects. Lets call this packaging "foo", defined by the "foo-plugin". I have no control over said plugin, but I want to extend it's lifecycle definition in my plugin.
I am writing another plugin, lets call this one the "bar-plugin". I want a certain goal of my plugin to be invoked in the process-sources phase of a project with "foo" packaging. Not in any other case. I have defined a mojo to execute in the process-sources phase but this makes it execute in the process-sources phase of any project, not just those with packaging "foo".
/**
* @goal bar
* @phase process-sources
*/
public class BarMojo extends AbstractMojo
I have also tried to use a custom lifecycle definition to extend the existing lifecycle, like this:
<component-set>
<components>
<component>
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
<role-hint>foo</role-hint>
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
<configuration>
<phases>
<process-sources>${groupId}:${artifactId}:${version}:bar</process-sources>
</phases>
</configuration>
</component>
</components>
</component-set>
This seemed to be totally ignored, even with the <extensions>
element in the pom set to true. Is it even possible to extend a lifecycle defined by one plugin using another plugin and if so, what am I doing wrong?
Edit:
The maven project structure is as follows: project-name (packaging)
mycompany-parent (pom)
- someprojecttype-parent (pom)
- - project-1 (foo)
- - project-2 (foo)
I want to add the plugin to someprojecttype-parent, which has packaging set to pom. This causes the bar goal to execute while building the parent project. I only want to execute the bar goal when building project-1 and project-2.