How to include or exclude files in Eclipse project

Directories excluded from a project in Eclipse
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:

Tried with: Eclipse Luna 4.4.2 and Ubuntu 14.04

2 thoughts on “How to include or exclude files in Eclipse project”

  1. Your proposed solution will remove the folder zoomba from the Project Navigator. But sometimes it is required to keep it there, but simply ignore it in indexer scope. For this, probably the setting Project Properties -> C/C++ General -> Paths and Symboles -> Source Location Tab -> exclude folder here.

    Indexer it is general problem in Eclipse. Do you maybe know where the Indexer Database is placed? It is interesting to check which folders are really included


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s