Maven build second level+ child projects using reactor option -pl

From the documentation for the -pl option it states the following:

-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.

The important part for you is: "or by its relative path".

So to build projectC, you simply need to refer to it by its relative path (projectB/projectC). So the command you need is:

mvn clean install -pl projectB/projectC

This is an answer from a similar question that is also relevant here.
By using artifactIds you don't have to know the structure of your project.


If you only use the artifactIds of the given project you have to define that correctly on command line:

help output of Maven (mvn --help)

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

This means in your case you have to define:

mvn clean install --projects :projectC,:ProjectY

Notice the : that is prepended to the artifactIds to indicate you omit the groupId

Tags:

Maven