Reputation: 4673
I have a maven project with some dependencies. Some of them have transitive dependencies which depend on, say, some jar A. I want to exclude this jar. Okay, I can add exclusions to every dependency which itself depends on A. But its a bit tedious. Is there any way to put this exclusion in one place in a maven project configuration?
Upvotes: 3
Views: 5827
Reputation: 4673
OKay, it looks like there is no way to do this.
According to documentation
Why exclusions are made on a per-dependency basis, rather than at the POM level
This is mainly done to be sure the dependency graph is predictable, and to keep inheritance effects from excluding a dependency that should not be excluded. If you get to the method of last resort and have to put in an exclusion, you should be absolutely certain which of your dependencies is bringing in that unwanted transitive dependency.
Upvotes: 0
Reputation: 32567
Use a parent pom where you have <dependencyManagement/>
. Then extend this parent in your POM files.
Alternatively, if it's one project that contains all these dependencies and they contain a transitive dependency with multiple versions on the dependency tree, define that dependency explicitly in your POM file and this will override the transitive versions.
See my explanations here for a similar question.
Upvotes: 3