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
?
Maven's Multi-Module Project A multi-module project is built from an aggregator POM that manages a group of submodules. In most cases, the aggregator is located in the project's root directory and must have packaging of type pom.
Now, the submodules are regular Maven projects, and they can be built separately or through the aggregator POM. By building the project through the aggregator POM, each project that has packaging type different than pom will result in a built archive file.
Note: When you specify a project with the -am option, Maven will build all of the projects that the specified project depends upon (either directly or indirectly). Maven will examine the list of projects and walk down the dependency tree, finding all of the projects that it needs to build.
Not sure if there is a command for that , but you can either view the pom file of your profile or the maven site generated out of the build to understand the hierarchy. Also at the end of the build there will be a list of modules which have been built , so perhaps a simple "mvn clean" will be enough to reveal all the modules.
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
mvn
seems to take the list you provide with -pl
to the heart and not build any dependencies automatically.
So in addition to Joe's answer: If the project/module you're trying to build depends on other modules then you can ask mvn
to build them as well with -am
.
-am,--also-make
If project list is specified, also build projects required by the list
If project list is specified = if -pl
option is used
So examples become:
mvn -pl maven-core -am
mvn -pl :maven-core -am
mvn -pl org.apache.maven:maven-core -am
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With