IntelliJ IDEA 14.0.0 Web Help

Configuring Content Roots

When created, a module, normally, has one content root.

You can create additional content roots as well as remove the unnecessary ones.

Specifying folder categories in the Project tool window

  1. Open the Project tool window (e.g. View | Tool Windows | Project ).
  2. Select the folder that you want to assign to test sources.
  3. In the context menu, point to Mark Directory As and select the desired category.
    mark-as-tests-project-tool-window

Folders within content roots can be assigned to the following categories: sources, test sources, generated sources, generated test sources and excluded folders (in Java modules - also resources and test resources). This can be done in the Project Structure dialog or in the Project tool window.

In Java modules, the folders marked as containing source code can be assigned a package prefix.

See also, Sources Tab.

Adding a content root

  1. Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).
  2. In the left-hand pane, select Modules.
  3. In the pane to the right, select the necessary module.
  4. In the right-hand part of the dialog, on the Module page, select the Sources tab.
  5. Click Add Content Root.
    add-content-root
  6. In the dialog that opens, select the folder to be added as a content root, and click OK.
  7. Click OK in the Project Structure dialog.

Specifying folder categories in the Project Structure dialog

  1. Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).
  2. In the left-hand pane, select Modules.
  3. In the pane to the right, select the necessary module.
  4. In the right-hand part of the dialog, on the Module page, select the Sources tab.
  5. Select the folder whose contents you want to assign to test sources and do one of the following:
    • To the right of Mark as, click Tests.
    • Select Tests in the context menu.
    mark-as-tests-project-structure
  6. Click OK in the Project Structure dialog.

Assigning a package prefix to a folder containing Java sources

  1. Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).
  2. In the left-hand pane, select Modules.
  3. In the pane to the right, select the necessary module.
  4. In the right-hand part of the dialog, on the Module page, select the Sources tab.
  5. In the right-hand pane, under Source Folders or Test Source Folders, click rootPrefix to the right of the necessary folder (folder path).
    assign-package-prefix
  6. In the dialog that opens, specify the package prefix and click OK.
  7. Click OK in the Project Structure dialog.

Removing a content root

  1. Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).
  2. In the left-hand pane, select Modules.
  3. In the pane to the right, select the necessary module.
  4. In the right-hand part of the dialog, on the Module page, select the Sources tab.
  5. To the right of the content root that you want to remove, click remove-x-icon.
    remove-content-root
  6. Confirm you intention to remove the content root. (The corresponding folder won't be physically deleted.)
  7. Click OK in the Project Structure dialog.

See Also

Last modified: 4 December 2014
comments powered by Disqus