Ryan Gabbard
Ryan Gabbard

Reputation: 2299

With IntelliJ IDEA, how can I exclude a directory from a project without opening the IDE?

For reasons beyond my control, many of my project directories must contain several symbolic links to directories containing huge numbers of files (potentially hundreds of thousands) on a network file system. These are located parallel to the root pom.xml.

When IntelliJ attempts to index these directories, it freezes up (I expect it would finish eventually). Often I can mark these directories as excluded so IntelliJ will not index them. However, these directories are sometimes created after initial project import. If IntelliJ catches them before I can mark them as excluded, it freezes. Worse, when I restart and attempt to open the project, it immediately freezes again.

How can I mark that these directories should be excluded without actually opening the project in IntelliJ IDEA?

Upvotes: 7

Views: 2439

Answers (1)

Ryan Gabbard
Ryan Gabbard

Reputation: 2299

You can edit the project file directly to exclude these directories. Find the .iml file for your project. Add excludeFolder elements under the content element like this:

<?xml version="1.0" encoding="UTF-8"?>
  <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
    <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
      <!-- other things will be here -->
      <content url="file://$MODULE_DIR$">
        <excludeFolder url="file://$MODULE_DIR$/directoryToExclude" />
        <excludeFolder url="file://$MODULE_DIR$/target" />
      </content>
      <!-- etc -->

Upvotes: 7

Related Questions