I'am not batman
I'am not batman

Reputation: 71

Overriding transitive version dependency in maven

What are the conditions to be met when using the <properties></properties tag to override a transitive dependency in maven? For example, in this sample github project (https://github.com/Richou/swagger-codegen-maven-plugin) I want to override the version of slf4j-ext used in swagger-codegen by defining the required version inside <properties> tag in the parent pom. What are the conditions for that?

NOTE: I understand that <dependencyManagement> can be used for this purpose but I want to get better insight on version overriding and how the pom works.

Upvotes: 1

Views: 1644

Answers (1)

cilap
cilap

Reputation: 2333

Typically you need to define a transitive dependency by tagging to a specific version.

lets say:

  1. your wished dependency needs a newer transitive dependency. In this case you have a issue with the newer dependency.
  2. your wished dependency needs a older transitive dependency In this case you want to have your newer dependency to use or not at all
  3. you need to upgrade a transitive dependency of a dependency itself? in this case exclude the dependency and add it as you own dependency

in the first case you can use dependency exclusion like explained here https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html#dependency-exclusions

In the later case you need to verify if your transitive dependency will work or if you need also to exclude the transitive dependency.

to upgrade the

Upvotes: 0

Related Questions