Search code examples
mavenpom.xmlparent-pom

How to ignore modules in my aggregator POM while executing a plugin


I need to execute a custom plugin on my aggregator POM that should checkout the sub modules. Since the sub-module folder(s) and hence the POM(s) do not exist yet, i always get error like:

The project ... has 1 error
[ERROR]     Child module ... of parentproject\pom.xml does not exist

Is it possible to ignore the modules while executing a plugin?

My Mojo Declaration

@Mojo(name = "checkout", aggregator = true)
public class CheckoutMojo extends AbstractMojo {

Solution

  • I was able to solve this by introducing a profile within the POM and moved all module names within the profile. Since maven doesn't find any module(s) when it ramps up it ramps up as expected, and then my mojo gets executed. Now the mojo that should run without modules being present is called like:

    mvn groupId:artifactId:version:goalname
    

    And the mojo that should run with modules is called like:

    mvn groupId:artifactId:version:goalname -Pprofile_having_modules