Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to include or exclude files in Eclipse project

📅 2015-Feb-11 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ eclipse, exclude, include, project ⬩ 📚 Archive

Directories excluded from a project in Eclipse

You may sometimes need to selectively include or exclude certain files or directories in an Eclipse project. For example, I had a data subdirectory in my Eclipse project with thousands of files. Eclipse would spend lots of time needlessly indexing these files. This can be prevented by just excluding that directory from the project.

  1. Right-click on the project and choose Properties. Choose Resource -> Resource Filters.

  2. In the Resource Filters dialog, click Add and choose which files and directories to either Include Only or Exclude All. Only provide the file or directory name, not a relative path or absolute path!

  3. Refresh the project to update these settings. The excluded files or directories should disappear from the project.

If you are curious, Eclipse puts this setting in the .project file for your project. For example, excluding a subdirectory named zoomba in a project, resulted in Eclipse adding this XML snippet to the .project:

    <filteredResources>
        <filter>
            <id>1433235573506</id>
            <name></name>
            <type>30</type>
            <matcher>
                <id>org.eclipse.ui.ide.multiFilter</id>
                <arguments>1.0-name-matches-false-false-zoomba</arguments>
            </matcher>
        </filter>
    </filteredResources>

Tried with: Eclipse Luna 4.4.2 and Ubuntu 14.04


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧