Search code examples
intellij-idea

In Intellij IDEa, how to set a rule for automatically excluding the folders that match it from indexing?


Intellij IDEa automatically excludes folders with a name like "target" for example. I want to define a rule for automatically exclude some folders depending on a specific pattern instead of excluding all of them manually.


Solution

  • Go into your project settings -> Modules menu.

    Choose the right module and mark the folder you don't want to index as excluded.

    This is the only way to do it. There is no automatic way to that.

    Mark folder as excluded

    If you have really to many folders to exclude, you can go into your PROJECT/.idea/modules folder. You should have an iml file for every module in your project. You will find a structure like

        <content url="file://$MODULE_DIR$/../..">
          <excludeFolder url="file://$MODULE_DIR$/../../.gradle" />
          <excludeFolder url="file://$MODULE_DIR$/../../build" />
          <excludeFolder url="file://$MODULE_DIR$/../../node_modules" />
          <excludeFolder url="file://$MODULE_DIR$/../../target" />
        </content>
        <orderEntry type="inheritedJdk" />
    

    You should be able to add all your exclude folders using some bash magic.

    HTH