Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transitive effect of dependencyManagement

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?

like image 630
J Fabian Meier Avatar asked Aug 08 '16 08:08

J Fabian Meier


People also ask

What is transitive dependency example?

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.

What is the purpose of the dependencyManagement block?

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.

What is transitive dependency in 3NF?

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 meant by transitive functional 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.


1 Answers

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:

  • your module
    • A - dependency
      • D - transitive dependency
    • B - dependency
      • D - transitive dependency

When 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.)

like image 144
Anton Koscejev Avatar answered Oct 19 '22 02:10

Anton Koscejev