IntelliJ IDEA 2016.3 Help

Dependencies Tab

On this tab, you can define the module SDK and form the list of module dependencies.

Main settings and controls

ItemDescription
Module SDK Select the module SDK. (To associate the project SDK with the module, select Project SDK. Note that if you change the project SDK later, the module SDK will change accordingly.)

If the desired SDK is not present in the list, click New and select the necessary SDK type. Then, in the dialog that opens, select the SDK home directory and click OK.

To view or edit the name and contents of the selected SDK, click Edit. (The SDK page will open.)

List of dependencies Shown below the module SDK is the list of module dependencies. Use /help/img/idea/2016.3/new.png, /help/img/idea/2016.3/delete.png, /help/img/idea/2016.3/arrowUp.png and /help/img/idea/2016.3/arrowDown.png to add, remove and reorder the items (libraries and modules). Use the cells in the header row to sort the list, see Sorting the list of dependencies.

When you compile or run your code, the list of dependencies is used to form the classpath for the compiler or JVM. (Native Library Locations, if any, are added to java.library.path rather than the classpath.)

Export. This option lets you control the compilation classpath for the modules that depend on this one.

Select the check box if you want the item to be exported as a dependency along with the module. That is, if there is a module that depends on this one, the items with the Export option on will be included in the compilation classpath of the dependent module.

Note that this setting doesn't affect the runtime classpath. At runtime, all the dependencies of the current module are included in the classpath for the modules that depend on this module.

Scope. This setting lets you control the classpath separately for your sources and test sources, and for the build and the run phases. (The classpath may be different when 1) your sources are compiled 2) your test sources are compiled 3) your compiled sources are run 4) your tests are run. The Scope option defines the classpaths in which the dependency is to be included.)

Select the necessary option from the list:

  • Compile. The dependency is included in the classpath for your sources and test sources at the compilation and run phases.
  • Test. The dependency is included in the classpath only for your test sources at the compilation and run phases.
  • Runtime. The dependency is included in the classpath for your sources and test sources but only at the run phase.
  • Provided. For your sources, the dependency is included in the classpath only at the compilation phase. This is useful when there is a container (e.g. a web container of an application server) that provides the corresponding dependency at runtime.

    For your test sources, the dependency is included in the classpath both at the build and run phases.

    Application server libraries, normally, are included in dependency lists with the scope Provided.

Note that IntelliJ IDEA is a bit different from some other build tools (e.g. Gradle and Maven) in the way it processes dependencies for test sources. If your module (say, module A) depends on another module (module B), IntelliJ IDEA assumes that the test sources in module A depend not only on the sources in module B but also on its test sources. Consequently, the test sources of module B are also included in corresponding classpaths.

/help/img/idea/2016.3/new.png (Alt+Insert). Use this icon or shortcut to add a library or a module to the list of the module dependencies. Select one of the following options:

  • Jars or directories. Select this option to create a new module library and add it to the list of dependencies. In the dialog that opens, select the files and folders to be included in the library. These may be individual .class and .java files, directories and archives (.jar and .zip) containing such files as well as directories with Java native libraries (.dll, .so or .jnilib).
  • Library. Select this option to add one or more of the existing project, global or application server libraries to the list of dependencies. In the dialog that opens, select the library or libraries and click Add Selected.
  • Module Dependency. Select this option to specify the modules that the current module should depend on.

/help/img/idea/2016.3/delete.png (Alt+Delete). Use this icon or shortcut to remove the selected item or items from the list of dependencies.

/help/img/idea/2016.3/arrowUp.png (Alt+Up) and /help/img/idea/2016.3/arrowDown.png (Alt+Down). Use these icons and shortcuts to move the selected item up or down in the list. See Order of dependencies.

/help/img/idea/2016.3/editFlexLibraryNew.png (F4). Use this icon or shortcut to open the Configure Library dialog to edit the library.

Dependency storage formatSelect the format for storing the dependencies (as an IntelliJ IDEA module, or as Eclipse project). This option is helpful for the teams that use different development tools.

Context menu commands for dependency items

ItemDescription
EditFor a library: use this command to edit the selected library. (The Configure Library dialog will open.)
Remove Use this command to remove the selected item or items from the list of dependencies.
Navigate (F4) Use this command or shortcut to see details for the selected item. An appropriate page of the Project Structure dialog will open, if any.
Find Usages Use this command to see the list of modules where the selected dependency is used. Clicking a module in that list, opens the Module Page for the corresponding module.
Analyze This DependencyUse this command to perform a dependency analysis for the selected item and display the results in the Dependency Viewer.
Move to Project Libraries or Move to Global Libraries For a module library: Use this command to move the selected library to a higher level (project or global).
Copy to Module LibrariesFor a global or project library: Use this command to create a copy of the selected library at the module level.

Sorting the list of dependencies

You can sort the dependencies by their names and scopes by clicking the cells in the header row.

If you click a cell once, the list is sorted by the corresponding column in the ascending order. The sorting marker appears in the cell: /help/img/idea/2016.3/sortMarkerAsc.png. When you click the cell for the second time, the information is sorted in the descending order. To show this, the sorting marker changes its appearance: /help/img/idea/2016.3/sortMarkerDesc.png. Finally, when you click the cell for the third time, the initial unsorted state is resorted.

Note that the sorting operations don't change the actual order of dependencies.

When the list is sorted, the icons for changing the order of dependencies are inactive.

See Also

Last modified: 21 March 2017