How can I exclude some folders from my Eclipse project?

EclipseProject

Eclipse Problem Overview


I'm adding an eclipse project to our existing code-base, and I'd like to know if there is a way to exclude some directories from being picked up by eclipse at all? The reason is that we have a huge "third-party" directory in our repository that cannot be present in the project for the pair-programming plugin we are using to be able to sync efficiently.

Any clues?

Eclipse Solutions


Solution 1 - Eclipse

There is a straight way to do it:

  1. Right-click a project folder in Project Explorer tree and go to "Properties".
  2. Resource -> Resource Filters.
  3. Add as many exclusion filters for files/folders as you like.

P.S. If your project tree is not updated automatically you may have to press F5 while having input focus in Project Explorer window.

Solution 2 - Eclipse

Filters will hide resources from view, but they're still in the project. If you create a project in another location you can create linked resources to the folders you want to include in your project.

For reference I posted another answer that describes how to use linked resources in more detail.

Solution 3 - Eclipse

Yes, you may place a custom filter on your project. In your project explorer view, there should be a white, downwards pointing arrow near the top of the panel by the Package Explorer tab. Click it, and go to Filters. From there, you can specify certain folder patterns you do not want detected by checking the box next to Name Filter Patterns. In this case, I would put the name of the 3rd party library.

Solution 4 - Eclipse

The way I've always done it is to explicitly check out projects as peers. e.g:

~/myworkspace/goodproject
~/myworkspace/3rdparty

then import only "goodproject" into eclipse. If "3rdparty" is a subdirectory of goodproject, you can fake it out... Say for example your svn project looks like this:

project/
src/
main/
3rdparty/

You can locally create project/src/ then checkout only the "main" directory, and have eclipse rely on a packaged version (e.g. point to the jar if your project is java).

Solution 5 - Eclipse

If you want to add filters directly inside .project file, these are some rules:

    <type>6</type> <!-- exclude all, files -->
    <type>5</type> <!-- include only, files -->
    <type>13</type> <!-- include only, files and folders -->
    <type>26</type><!-- exclude all, folders, all children -->

    <arguments>1.0-name-matches-false-false-xyz</arguments> <!-- case sensitive=false, regular expression=false, something named=xyz -->
    <arguments>1.0-name-matches-true-false-EEE</arguments> <!-- case sensitive = true, regular expression = false, something named=EEE -->
    <arguments>1.0-name-matches-false-false-www</arguments> <!--case sensitive=false, regular expression = false, something named=www -->

One .project filter section for example:

    <filteredResources>
		<filter>
			<id>1567020347706</id>
			<name></name>
			<type>6</type> <!-- exclude all, files -->
			<matcher>
				<id>org.eclipse.ui.ide.multiFilter</id>
				<arguments>1.0-name-matches-false-false-abc</arguments>
			</matcher>
		</filter>
		<filter>
			<id>1567020347708</id>
			<name></name>
			<type>5</type> <!-- include only, files -->
			<matcher>
				<id>org.eclipse.ui.ide.multiFilter</id>
				<arguments>1.0-name-matches-false-false-xyz</arguments> <!-- case sensitive=false, regular expression=false -->
			</matcher>
		</filter>
		<filter>
			<id>1567020347711</id>
			<name></name>
			<type>13</type>
			<matcher>
				<id>org.eclipse.ui.ide.multiFilter</id>
				<arguments>1.0-name-matches-false-false-mno</arguments>
			</matcher>
		</filter>
		<filter>
			<id>1567020347713</id>
			<name></name>
			<type>26</type><!-- exclude all, folders, all children -->
			<matcher>
				<id>org.eclipse.ui.ide.multiFilter</id>
				<arguments>1.0-name-matches-true-false-EEE</arguments> <!-- case sensitive = true, regular expression = false -->
			</matcher>
		</filter>
		<filter>
			<id>1567020347716</id>
			<name></name>
			<type>26</type> <!-- exclude all, folders, all children -->
			<matcher>
				<id>org.eclipse.ui.ide.multiFilter</id>
				<arguments>1.0-name-matches-false-false-www</arguments> <!-- case sensitive = false, regular expression = false -->
			</matcher>
		</filter>
    </filteredResources>

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
QuestionjkpView Question on Stackoverflow
Solution 1 - EclipseGleb VarenovView Answer on Stackoverflow
Solution 2 - EclipseRich SellerView Answer on Stackoverflow
Solution 3 - EclipseAlbertoPLView Answer on Stackoverflow
Solution 4 - EclipseinanutshellusView Answer on Stackoverflow
Solution 5 - EclipsedaniloView Answer on Stackoverflow