In Maven you can override the version number of a transitive dependency by an entry in dependencyManagement because dependencyManagement takes precedence over transitive dependency definitions.
But what about dependencyManagement definitions in the poms of (transitive) dependencies? Are they considered at all? If so, what do they override, how are they overridden?
Transitive Dependencies. A transitive dependency exists when you have the following functional dependency pattern: A → B and B → C ; therefore A → C. This is precisely the case with the original items relation.
The dependency management plugin improves Gradle's handling of exclusions that have been declared in a Maven pom by honoring Maven's semantics for those exclusions. This applies to exclusions declared in a project's dependencies that have a Maven pom and exclusions declared in imported Maven boms.
A relation that is in First and Second Normal Form and in which no non-primary-key attribute is transitively dependent on the primary key, then it is in Third Normal Form (3NF). Note – If A->B and B->C are two FDs then A->C is called transitive dependency.
What is Transitive Dependency in DBMS? Whenever some indirect relationship happens to cause functional dependency (FC), it is known as Transitive Dependency. Thus, if A -> B and B -> C are true, then A -> C happens to be a transitive dependency. Thus, to achieve 3NF, one must eliminate the Transitive Dependency.
Dependency management is implied to be transitive. There doesn't need to be a special rule for this, but rather it's a consequence of the already mentioned rules: Transitive Dependencies.
Consider this example structure:
A
- dependency
D
- transitive dependencyB
- dependency
D
- transitive dependencyWhen A
or B
are built, their corresponding dependencyManagement
section is checked to pick version for D
, if it's not explicitly specified. Here's the important part: exactly the same process is used when A
or B
are used as dependencies to determine which version of D
they depend on. Consequently, they do not affect each other in any way.
This could result, for example, in A
depending on D:1.0
, and B
depending on D:1.1
, their dependencyManagement
sections have already been applied at this point to determine this and will not be taken into account anymore. With this information as input, dependency mediation rules are applied to pick just one version of D
for your module.
Dependency mediation rules are also described in the linked page. But in a nutshell, the nearest definition wins and ties are broken based on order. Naturally, definitions in your module itself are always the nearest.
Now let's say your module is used as a dependency. Your project could depend on D:1.2
based on all the rules above due to a definition in your dependencyManagement
section, but that's where the scope of your dependencyManagement
ends.
(Note that import
scope is an exception as it behaves completely differently from the other scopes.)
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