We have a Maven multi-module project with some 30 child projects/module in it.
All child projects where using those two dependencies. (This is just to put something concrete in the example)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra-reactive</artifactId>
</dependency>
Hence, we refactored and put those two dependencies to the parent POM. The snippet from above is now in the parent level. All child projects could still benefits from it, and have to only maintain the version in one place, all very happy.
We now have a 31st project which fits the business use cases and fits inside this multi module project, we believe it makes sense to have it under this same parent POM.
However, this 31st project does not need one particular dependency from the Parent POM. (In this case the Cassandra dependency, but the question is about how to exclude something from the parent)
Having this 31st project part of this multi module, he also takes this dependency (Cassandra) from the parent. How to tell this child project to exclude this dependency from the parent?
I do not want to extract this project entirely and have it separated from the multi module.
I tried putting an exclusion in ALL dependencies, but it is still there. Like in all dependencies of my child pom, I write this:
<dependency> <groupId>some.group</groupId> <artifactId>some.artifact</artifactId> <exclusions> <exclusion> <!-- declare the exclusion here --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-cassandra-reactive</artifactId> </exclusion> </exclusions> </dependency>
I even tried doing the crazy refactor of moving the dependency away from the parent back to all children, and did 30 copy paste to the child, with my 31st project not having it. This works, but I believe there is something smarter than that.
How to exclude one particular dependency from the Parent POM please?