Reputation: 18542
I'm sure this is probably a duplicate question, but I'm trying to understand why...
A, B and C are plain old Java modules - A and B are libraries, C is an application.
if B depends on A
and C depends on B
why do I have to include both A and B in C's dependencies?
I'm not looking for advice really - I've only got 5 modules in the project so it's no big deal. I'm just curious as to why this is the case (or maybe I am missing something obvious).
Upvotes: 2
Views: 71
Reputation: 726967
There are two kinds of dependencies to consider - project dependencies, and run-time dependencies.
Run-time dependencies are the simplest ones: you need JARs for both A and B in order to run C, because without A, B would not be able to run. Java modules are similar to dynamic libraries in other compiled languages (as opposed to static libraries). When you compile B, the compiler does not make copies of A's classes to be included with B: it assumes that A, B's dependency, will be available at run-time.
Project dependencies are less straightforward: strictly speaking, you do not need to include A in the list of dependencies of C. Most development environments will figure out transitive dependencies for you, so when A changes, B would recompile, and then C would recompile in response to B's recompile.
Upvotes: 1