Module

Edit page Last modified: 29 九月 2022

A module is a discrete unit of functionality that can be run, tested, and debugged independently. Modules include such things as source code, build scripts, unit tests, deployment descriptors, etc.

The key components of a module are:

  • Content roots - the directories where the files belonging to the module (source code, resources, etc.) are stored. Each directory can belong to one and only one module; it's not possible to share a content root between multiple modules.

  • Source roots - A content root can have multiple source roots underneath it. Source roots can have different types: regular source roots, test source roots, resource roots, etc. In IntelliJ IDEA, source roots are used as roots of the package hierarchy structure. Java classes directly under a source root will be in the root package. Source roots can also be used to implement more fine-grained dependency checks. Code under a regular source root cannot depend on code under a test source root.

    tip

    Not all other IntelliJ Platform-based IDEs use source roots.

  • Order entries - the dependencies of a module, which are stored in an ordered list. A dependency can be a reference to an SDK, a library, or another module.

  • Facets - the list of framework-specific configuration entries.

In addition to that, a module can store other settings, such as a module-specific SDK, compile output path settings, etc. Plugins can store additional data associated with a module by creating facets or module-level components.

The IntelliJ Platform provides a number of classes and interfaces you can use to work with modules:

This section discusses how to complete some common tasks related to management of modules.

See Changing the Project Structure for information on modifying project/module structure.