mavenbuildmodulemulti-project

Define modules list which shall be built in Maven multiproject build


I would like to use Maven -pl option to define which specific modules shall be included into reactor. The option works if list of module's paths is provided. Unfortunately, providing module's artifactIds is not working at all.

Sonatype: Maven: The Complete Reference docs are using multiproject example where directories names are matching artifactIds:

Is it possible to use -pl option with artifactId?


Solution

  • Yes, it's possible to do this. Take a look at mvn --help:

     -pl,--projects <arg>                   Comma-delimited list of specified
                                            reactor projects to build instead
                                            of all projects. A project can be
                                            specified by [groupId]:artifactId
                                            or by its relative path.
    

    Note in particular that an artifactId without a leading groupId still has a leading colon.

    So, for example in a case where the artifactId is the same as the directory name, these three lines would all refer to the same module in Maven: