27

I am working a C++ codebase that is built & run outside Eclipse.

I made an Eclipse project out of it where I just use Eclipse for browsing/editing the code.

However, I can't figure out how to completely exclude certain directories like build/ from it completely. They should be excluded not only during building but also during "Refresh workspace" which seems to get triggered so often. To give an example, my workspace is

d:\workspace

It has directories like

source/
build/
..

During startup, Eclipse picks up all directories inside the workspace automatically. However, I would like Eclipse to exclude build/ completely.

My code is on a remote machine, so "Refresh workspace" slows things down.

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
user674669
  • 10,681
  • 15
  • 72
  • 105
  • This is exactly what i was also looking for...its similar to the excude from project feature in Visual Studio. Yea and you got it right i think they provide only as good as exclude from build which is annoying as i can still see the files in striked out form. – FUD Sep 21 '11 at 11:35
  • What effects do you want the exclusion to have? – Ciro Santilli OurBigBook.com Aug 17 '17 at 08:04
  • Very closely related: [How to filter resource folders in a certain subpath of the project only?](https://stackoverflow.com/questions/14221589/how-to-filter-resource-folders-in-a-certain-subpath-of-the-project-only) – Gabriel Staples Dec 06 '21 at 21:34
  • Also very closely related (my own Q&A I just added): [How to exclude all parts of a folder in Eclipse except for a few specific sub-folders within it](https://stackoverflow.com/q/70267494/4561887) – Gabriel Staples Dec 08 '21 at 00:12

3 Answers3

29

You can do it by adding Resource filters. Add Exclude All resource filter type to root folder of your project. See also this answer.

Community
  • 1
  • 1
ks1322
  • 33,961
  • 14
  • 109
  • 164
  • 4
    To accomplish this, you probably want to right-click your project folder, select properties and then search for `resource filters` – AturSams Oct 13 '15 at 12:24
  • 2
    See http://stackoverflow.com/questions/14221589/how-to-filter-resource-folders-in-a-certain-subpath-of-the-project-only for detailed instructions on how to filter a specific, relative, subfolder. – zpon Apr 21 '16 at 10:17
  • Can you add some detailed examples? I find excluding or including subfolders by name or relative path **impossible**, and I've spent *hours* trying. – Gabriel Staples Dec 06 '21 at 19:43
  • I figured it out. It _is_ mostly impossible due to what appears to be the existence of some rather troublesome Resource Filter bugs. But, I have a work-around, and have carefully documented it in my answer here: [How to exclude all parts of a folder in Eclipse except for a few specific sub-folders within it](https://stackoverflow.com/a/70267495/4561887) – Gabriel Staples Dec 08 '21 at 00:10
4

I am very firmly of the opinion that all answers for questions like this need to include the version in which they have been tested-- because, like most things in Eclipse, this has gradually changed. In Eclipse Neon.3 (4.6.3), you can do this more directly.

NOTE: The excluded directory will no longer show up in the Project Explorer tree AT ALL.
If this will be a problem, select a different technique!


Otherwise, proceed as follows:

1. Left-click the project root in the Project Explorer tree to ensure proper context (you "shouldn't need to do this"-- like a lot of things in Eclipse).
2. Right-click the folder you wish to exclude in the Project Explorer tree.
3. Select the "Resource Configurations..." submenu.
4. Select "Exclude from Build".
5. Right-click the project root in Project Explorer.
6. Select the "Index" submenu.
7. Select "Rebuild".

If you were trying to do this because you were getting duplicate symbols, verify this has fixed your problem:

1. Open a file referencing the symbol that was getting duplicate definitions.
2. Left click the actual characters of the actual name in the actual code.
3. Press F3.
4. Verify that you either go immediately to the declaration you consider
correct, you see a list including only that entry and its ancestors.
5. Upvote this answer, and reply if you find that it works with a newer version, please.

breakpoint
  • 916
  • 9
  • 16
2

A quick fix that is almost as good (in terms of reducing Eclipse wheel-spin) is to mark the folder(s) in question as Derived, in (right-click) Properties.

Be careful if you subsequently want to use the text search operations for something and need to include things marked Derived - you need to explicitly 'include Derived' in the search.

MikeW
  • 5,504
  • 1
  • 34
  • 29
  • 1
    Thank you, this helps me! For some reason, there has been created a directory `build` in my workspace. I must always remove it from all search results, but now it is gone. – Juha M Jan 09 '21 at 18:24