I use maven 3.2.3.
I have a multi-module project with three levels of nested modules. I want to build all first-level modules(with their submodules) except one. For this task I tried to use -pl option and specifying the module I want to exclude from the build using !moduleName.
What I have in result is that the specified module is excluded from the build, BUT submodules of that module are not.
Is it an expected behaviour and I should explicitly exclude all the nested submodules as well?
Open the dependency POM and find the transitive dependency you want to exclude. Copy groupId and artifactId . In your project POM, underneath your active dependency, enter exclusions and using code completion paste the copied info of the dependency you want to exclude.
Exclusions are set on a specific dependency in your POM, and are targeted at a specific groupId and artifactId. When you build your project, that artifact will not be added to your project's classpath by way of the dependency in which the exclusion was declared.
One of the best benefit of using Spring Boot based multi-module project is the ability to define the global dependencies at one place and let the child module re-use these configurations without duplicating it. The interesting part of this pom. xml is the <parent> tag.
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. The submodules are regular Maven projects, and they can be built separately or through the aggregator POM.
The short answer is: yes it is expected behavior.
The feature request that documents this change (allowing you to use !moduleName
to exclude a specific module from the build) is documented in issue MNG-5230.
In that request someone specifically asks for the functionality you are looking for:
how about excluding nested modules? I tried the new feature and it seems as though, when a top module is excluded, its nested modules are not.
and the answer there is:
Nested modules are not excluded by parent module.
So looks like you'll have to list them all individually.
If you are always excluding the same modules you could predefine this list in a profile that is either activated or deactivated as required. Details of this can be seen in this answer: https://stackoverflow.com/a/5542779/1570834
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