Define modules list which shall be built in Maven multiproject build

build, maven, module, multi-project

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:

- `mvn -pl maven-core`

- `mvn -pl :maven-core`

- `mvn -pl org.apache.maven:maven-core`

Problem

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: - Using Advanced Reactor Options Is it possible to use `-pl` option with `artifactId`?

Original source