如何从Eclipse项目中排除某些文件夹?

时间:2023-01-17 10:46:46

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.

我正在为我们现有的代码库添加一个eclipse项目,我想知道是否有办法将某些目录排除在eclipse之外?原因是我们的存储库中有一个巨大的“第三方”目录,它不能出现在我们用来有效同步的配对编程插件的项目中。

Any clues?

4 个解决方案

#1


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.

作为参考,我发布了另一个答案,该答案描述了如何更详细地使用链接资源。

#2


There is a straight way to do it:

有一种直接的方法:

  1. Right-click a project folder in Project Explorer tree and go to "Properties".
  2. 在项目浏览器树中右键单击项目文件夹,然后转到“属性”。

  3. Resource -> Resource Filters.
  4. 资源 - >资源过滤器。

  5. Add as much exclusion filters for files/folders as you like.
  6. 根据需要为文件/文件夹添加尽可能多的排除过滤器。

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

附:如果项目树未自动更新,则可能必须在项目浏览器窗口中输入焦点时按F5。

#3


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.

是的,您可以在项目中放置自定义过滤器。在项目资源管理器视图中,“包资源管理器”选项卡旁边的面板顶部应该有一个白色的向下箭头指示箭头。单击它,然后转到过滤器。从那里,您可以通过选中名称过滤模式旁边的框来指定您不想检测的某些文件夹模式。在这种情况下,我会把第三方库的名称。

#4


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:

然后只将“goodproject”导入eclipse。如果“3rdparty”是goodproject的子目录,你可以伪造出来......比如说你的svn项目看起来像这样:

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).

您可以在本地创建project / src /然后仅检出“main”目录,并让eclipse依赖打包版本(例如,如果您的项目是java,则指向jar)。

#1


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.

作为参考,我发布了另一个答案,该答案描述了如何更详细地使用链接资源。

#2


There is a straight way to do it:

有一种直接的方法:

  1. Right-click a project folder in Project Explorer tree and go to "Properties".
  2. 在项目浏览器树中右键单击项目文件夹,然后转到“属性”。

  3. Resource -> Resource Filters.
  4. 资源 - >资源过滤器。

  5. Add as much exclusion filters for files/folders as you like.
  6. 根据需要为文件/文件夹添加尽可能多的排除过滤器。

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

附:如果项目树未自动更新,则可能必须在项目浏览器窗口中输入焦点时按F5。

#3


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.

是的,您可以在项目中放置自定义过滤器。在项目资源管理器视图中,“包资源管理器”选项卡旁边的面板顶部应该有一个白色的向下箭头指示箭头。单击它,然后转到过滤器。从那里,您可以通过选中名称过滤模式旁边的框来指定您不想检测的某些文件夹模式。在这种情况下,我会把第三方库的名称。

#4


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:

然后只将“goodproject”导入eclipse。如果“3rdparty”是goodproject的子目录,你可以伪造出来......比如说你的svn项目看起来像这样:

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).

您可以在本地创建project / src /然后仅检出“main”目录,并让eclipse依赖打包版本(例如,如果您的项目是java,则指向jar)。