87

我正在向我们现有的代码库添加一个 eclipse 项目,我想知道是否有办法完全排除某些目录被 eclipse 拾取?原因是我们的存储库中有一个巨大的“第三方”目录,该目录不能出现在我们用来高效同步的结对编程插件的项目中。

有什么线索吗?

4

5 回答 5

201

有一个直接的方法来做到这一点:

  1. 右键单击项目资源管理器树中的项目文件夹,然后转到“属性”。
  2. 资源 -> 资源过滤器。
  3. 根据需要为文件/文件夹添加尽可能多的排除过滤器。

PS 如果您的项目树没有自动更新,您可能必须在 Project Explorer 窗口中输入焦点时按 F5。

于 2011-06-12T11:23:19.037 回答
16

过滤器将从视图中隐藏资源,但它们仍在项目中。如果您在其他位置创建项目,则可以将链接资源创建到要包含在项目中的文件夹。

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

于 2009-07-27T12:30:45.907 回答
6

是的,您可以在项目中放置自定义过滤器。在您的项目浏览器视图中,Package Explorer 选项卡旁边的面板顶部附近应该有一个白色的向下箭头。单击它,然后转到过滤器。从那里,您可以通过选中名称过滤器模式旁边的框来指定您不希望检测到的某些文件夹模式。在这种情况下,我会输入第 3 方库的名称。

于 2009-07-27T12:26:06.310 回答
1

我一直这样做的方式是明确地检查项目作为同行。例如:

~/myworkspace/goodproject
~/myworkspace/3rdparty

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

项目/
       源/
          主要的/
          第三方/

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

于 2009-07-27T12:40:16.143 回答
1

如果你想直接在.project文件中添加过滤器,这些是一些规则:

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

例如,一个.project过滤器部分:

    <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>
于 2019-08-28T19:36:55.710 回答