Exclude folders from Eclipse search

EclipseSearch

Eclipse Problem Overview


Is there a way to exclude certain folders (and all their subfolders) from searching within Eclipse?

Eclipse Solutions


Solution 1 - Eclipse

The quick and dirty way:

Right click on a folder, go to properties, and mark a folder as derived. Derived entities are excluded from searching by default. The problem with this approach is that Eclipse "forgets" that the folder is derived if you delete it (either from within Eclipse or externally, followed by refreshing the project tree). Like so often with Eclipse, this is a long-standing bug (10 years in this case) which still applies to the current version (4.6 Neon at the time of writing).

The safe way:

Create a working set including only those entities you want searched and search only within that working set. See Dave Ray's answer for details on this procedure.

Solution 2 - Eclipse

Here is what works for me (I'm using Helios - maybe this way was not available when this question was originally asked?)

  • Go to Project -> Properties -> Resource Filters.
  • Click Add.
  • Choose Filter type: Exclude all
  • Choose Applies to: Folders; check All children (recursive).
  • In the Attributes, choose Name, Matches, .svn (for example).

(Actually, I'm using .* to filter out .svn, .hg etc. in one go.)

After okay'ing the project properties dialog, these directories won't come up in search any more. In fact, Eclipse is so kind as to automatically update existing search results windows and remove all matches which are now filtered out.

Solution 3 - Eclipse

I could imagine that marking resources derived might cause problems in other areas. Instead, create a working set with the folders you want to include in the search:

  • Open Search dialog (Ctrl + H)
  • Change search scope to Working Set
  • Click Choose ...
  • Click New to create a new Working Set with the what you want searched (or Add All and then remove the ones you want filtered

Solution 4 - Eclipse

  • Right click on your project
  • Select Properties
  • Select Resource -> Resource filters
  • Click Add filter
  • Choose the following settings:
    • Exclude all
    • Files and folders
    • All children (recursive)
  • Change Name for Project Relative Path
  • Fill input text with (bin$|bin/.*|build/.*|build$) (replace bin and build by the names of the folders you want to exclude)
  • Tick Regular expression

Hit OK and then Apply.

Disclaimer

This builds on @atzz's answer, which helped me figure this out. However while it did answer the question of how to exclude certain files, it didn't answer the question of how to exclude certain folders.

Solution 5 - Eclipse

The best quick and dirty way in Eclipse Juno:

  1. Right click on the folder.
  2. Go to Properties.
  3. Go to C/C++ Build.
  4. Check "Exclude resource from build".
  5. Click in OK button.
  6. Right click on the project.
  7. Go to Index.
  8. Click Rebuild.
  9. Relax!

Solution 6 - Eclipse

Excluding a folder or file from being searched in Eclipse

1 Right-click on the file/folder.
3 Click on the "Properties" option.
4 Select the "Resource" option.
5 Place a check next to the "Derived" attribute.

Hope is help.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDónalView Question on Stackoverflow
Solution 1 - EclipseInstantsoupView Answer on Stackoverflow
Solution 2 - EclipseatzzView Answer on Stackoverflow
Solution 3 - EclipseDave RayView Answer on Stackoverflow
Solution 4 - EclipseVic SeedoubleyewView Answer on Stackoverflow
Solution 5 - EclipseDiFSView Answer on Stackoverflow
Solution 6 - EclipsesuperupView Answer on Stackoverflow