Module dependencies are the entities that a module uses and, consequently, depends on. So, the term module dependency may refer to:
- The SDK associated with the module
- Libraries used in the module
- Other modules belonging to the same project
Order of dependencies
The module dependencies are processed in the order in which they appear in the corresponding list (see Dependencies tab).
At compile time, the order of items in the list defines the order in which the compiler (javac) looks for the classes to resolve the corresponding references. At runtime, this list defines the order in which the JVM searches for the classes to be loaded.
In certain situations, the order of libraries may be important. For example, if you want to use patches to certain libraries, these patches should be placed in the list before (above) the main libraries. Otherwise, new versions of the classes (contained in the patches) will be ignored.
For compilation, the position of an item in the list in relation to the module SDK (JDK) also matters, and in certain cases may be very important. (The module SDK is always shown in the list among the module dependencies.)
All the items after the JDK are translated into the module
classpathentries. Most of the libraries that you normally deal with should go there.
All the items before the JDK correspond to the module
For the compilation to succeed, certain libraries (e.g. the ones having to do with the JDK itself and its extensions) must be included in the module
bootclasspath. So, such libraries must appear in the list before the JDK.
The use of such libraries, however, may be necessary in a very limited number of special cases. Thus, for the most of your modules, the JDK will (and should) be the first item in the list of dependencies.
Dependencies on other modules
If a module (module A) depends on another module (module B), IntelliJ IDEA assumes that:
- The sources of module A depend on the sources in module B and don't depend on its test sources.
- The test sources of module A depend on the sources and the test sources of module B.