如何排除 Eclipse 项目中产生警告/错误的文件夹?

发布于 2024-09-19 21:19:04 字数 2029 浏览 9 评论 0原文

好的。我厌倦了这个问题。这个必须有一个简单的解决办法,我确信这一点!我希望SO能帮助我一劳永逸地摆脱这个问题!

问题

我们如何让 Eclipse 停止尝试 处理/编译 a 下的所有文件 特定的项目目录?这 目标是没有错误/警告 存在于问题视图中,如果 与此文件夹或其子文件夹中的某些内容相关。

背景

我们运行 Eclipse 3.6,m2eclipse 插件 v0.10.2.20100623 管理我们的自动构建。由于我无法控制的原因,我们在 SVN 项目目录中的 src/main/resources/blazeds 下拥有整个 BlazeDS 发行版。本质上,该目录包含运行 blazeds 的 tomcat 的普通发行版,当我们通过 SCP 部署到服务器时,所有配置和项目文件都会添加到其中。

所以,当我们运行deploy时,这个版本的tomcat就会被复制到服务器上,我们的项目就放在里面了。 Tomcat 和我们的 RIA 应用程序工作正常,一切都很好。

问题是,运行 AutoBuild 时 Eclipse 会尝试编译 src/main/resources/blazeds 下的所有内容,这会在我们的问题视图中生成大约 300 个错误/警告。因此,当真正的错误出现时,它就会被淹没在噪音中。

这些错误源于 /blazeds/tomcat/webapps/samples/testdrive-datapush 中的代码以及 testdrive-httpservicetraderdesktop 示例 Web 应用程序。它们具有不在类路径上的依赖源代码和不包含在库中的 jar。

失败的尝试解决方案

我正在尝试推出正确的解决方案:完全删除示例并摆脱我们的版本控制。这种情况不会很快发生。

我遵循了 所以在这里回答但这只是一个非常临时的解决方案。我尝试在所有我能想到的地方添加排除项,我的团队的其他成员也做了同样的事情。我已删除 src/main/resources 作为源目录(在首选项 > Java 构建路径 > 源选项卡中)我已在资源下添加了 blazeds 的排除项目录。我已经尝试了 blazeds** 的每种排列,如 *blazeds***/blazeds/**

我什至尝试过包含编译器抱怨的库和源文件,但如果不过度破坏我们的项目配置,我就无法正确执行它

摘要

这必须很简单。什么是 排除文件夹的常规方法 这会产生警告/错误 一个 Eclipse 项目?

<小时> 更新 #1:
下面的gedim解决方案很不错,但是
1) 没有从项目中清除红色 X
2) 是我们团队中每个人都需要手动进行的更改
(即,它不在项目属性文件中;因此,它不会被签入 subversion)

我希望有一种方法可以通过告诉 Eclipse 该目录不包含来解决核心问题
要编译/验证的项目。这样的更改可能会出现在项目设置文件之一中。


Update #2:

下图显示了我正在尝试清除的红色 X
构建路径>排除
不是一个选项...

红色 X 不会消失

Okay. I'm sick of this problem. This has to have an easy fix, I'm sure of it!! I hope SO can help me to get rid of this once and for all!

Question

How do we get Eclipse to stop trying
to process/compile all files under a
particular project directory? The
goal is for no errors/warnings to
exist in the problems view if they
relate to something in this folder or it's subfolders.

Background

We run Eclipse 3.6 and the m2eclipse plugin v0.10.2.20100623 manages our autobuild. For reasons beyond my control, we have the entire BlazeDS distribution in our SVN project directory under src/main/resources/blazeds. Essentially, this directory contains a vanilla distribution of tomcat running blazeds to which all our configuration and project files are added when we deploy to our server via SCP.

So, when we run deploy, this version of tomcat is copied to the server and our project is placed inside. Tomcat and our RIA application work and everything is fine.

The problem is, Eclipse tries to compile everything under src/main/resources/blazeds when running AutoBuild and this generates about 300 errors/warnings in our problem view. So when a real error surfaces, it gets lost among the noise.

The errors stem from code in /blazeds/tomcat/webapps/samples/testdrive-datapush and also the testdrive-httpservice, traderdesktop example webapps. They have dependent source code that's not on the classpath and jars that aren't included in the libraries.

Failed Attempted Solutions

I'm trying to push the proper solution: to remove the samples completely and also to get blazeds out of our version control. That's not happening anytime soon.

I've followed the SO answer here but it's only a very temporary solution. I've tried adding exclusions everywhere I can think of and other members of my team have done the same. I've removed src/main/resources as a source directory (in preferences > Java Build Path > Source Tab) I've added exclusions for blazeds under the resource directory. I've tried every permutation of blazeds and ** as in *blazeds*, **/blazeds/**, etc.

I've even tried including the libraries and source files the compiler is complaining about but I couldn't get it right without excessively mangling our project configuration.

Summary

This has to be simple. What is the
conventional way to exclude a folder
that is producing warnings/errors in
an eclipse project?


Update #1:
gedim's solution below is decent but it
1) doesn't clear red X's from the project
2) is a change everyone on our team needs to do, manually
(i.e., it's not in a project property file; thereby, it isn't checked into subversion)

I hope there's a way to address the core problem by telling Eclipse that this directory doesn't contain
items to compile/validate. Such a change would likely show up in one of the project setting files.


Update #2:

The picture below shows the red X's I'm trying to clear and that
Build Path > Exclude
isn't an option...

Red X's won't go away

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

ペ泪落弦音 2024-09-26 21:19:04

我遇到了类似的问题,并通过将文件夹移动到我的项目文件夹中来解决它。然后我去了:

  1. 项目>;属性>资源>资源过滤器>添加...
  2. 设置过滤器类型 = 全部排除
  3. 设置应用于 = 文件夹
  4. 设置文件和文件夹属性 = { 名称、匹配项、你的文件夹名称> }

I encountered a similar problem and resolved it by moving the folder into my project folder. I then went to:

  1. Project > Properties > Resource > Resource Filters > Add...
  2. Set Filter type = Exclude all.
  3. Set Applies to = Folders.
  4. Set File and Folder Attributes = { Name, matches, < your_folder_name > }
堇年纸鸢 2024-09-26 21:19:04

您可以使用问题面板菜单上的配置内容...。您可以在此处创建新配置并将范围设置为在工作集:。单击选择... 并创建一个新的工作集,其中排除您不需要的文件夹。

You can use the Configure Contents... on the menu of Problems panel. There you can create a new configuration and set the scope to On Working Set:. Click on Select... and create a new working set that excludes the folders you don't want.

半边脸i 2024-09-26 21:19:04

有一个 Eclipse 功能请求忽略来自指定源文件夹的警告。评论线程中已经发布了多个补丁,提供了该功能的实现。最终补丁似乎已接近审查阶段,以便包含在即将发布的版本中。

更新 6/19/2012:Eclipse Juno 4.2M6 支持忽略特定源文件夹的问题。该功能在 Java 构建路径对话框中可用。请参阅发行说明

There is an Eclipse feature request for ignoring warnings from specified source folders. There have been several patches posted to the comment thread that provide implementations of the feature. It appears that a final patch is nearing the review stage for inclusion in an upcoming release.

Update 6/19/2012: Eclipse Juno 4.2M6 supports ignoring problems for a particular source folder. The feature is available on the Java Build Path dialog. See the release note.

静谧 2024-09-26 21:19:04

如果您确实想从自动构建中排除某些类/包,您可以右键单击它们并选择“构建路径”->“构建路径”。排除

alt text

If you really want to exclude certain classes/packages from autobuild you can just right click on them and select Build Path -> Exclude

alt text

晒暮凉 2024-09-26 21:19:04

将您的项目(项目/属性/Java 构建路径/源)配置为仅包含您想要编译的文件夹列表,而不是包含排除的顶级 src 文件夹。

假设 Eclipse Helios,一步一步:

  • 关闭自动构建(Project/Build
    自动地)。
  • 从空开始。
  • 右键删除错误
    如链接中所示(只是为了确定)。
  • 一一添加正版源文件夹
    (项目/属性/Java 构建
    路径/源/添加文件夹)
  • 执行显式构建(项目/构建项目)。

如果有效,您应该能够重新打开自动构建。如果没有,就会发生奇怪的事情。也许该项目没有使用标准的 Java Builder,而是使用类似 Ant Builder 的东西(项目/属性/构建器)。

Configure your project (Project/Properties/Java Build Path/Source) to have, instead of the top level src folder with exclusions, just a list of the folders you do want to compile.

Assuming Eclipse Helios, step by step:

  • Turn off autobuild (Project/Build
    Automatically).
  • Start with it empty.
  • Delete the errors by right clicking
    as in the link (just to be sure).
  • Add genuine source folders 1 by 1
    (Project/Properties/Java Build
    Path/Source/Add Folder)
  • Do an explicit build (Project/Build Project).

If that works, you should be able to turn autobuild back on. If it doesn't, something strange is going on. Perhaps the project is not using the standard Java Builder, but something like an Ant Builder (Project/Properties/Builders).

攒眉千度 2024-09-26 21:19:04

转到 Java 构建路径 ->来源->添加文件夹

选择需要成为构建路径一部分的正确文件夹

在上面的屏幕截图中,需要从构建中删除 src/main/resources,因为它会导致编译错误 [错误的包 ID]。因此,将文件夹包含到 src/main/resources 为止。

我确实尝试过构建路径 ->排除。这并不能真正解决问题。即,尽管 RedX 标记已从 Eclipse 中清除,但它不再是正确的 Java 项目。即用户可能无法运行 JUnit 测试用例/调试等。

但是通过包含正确的文件夹,我们可以继续作为 Java 项目。

Go to Java Build Path -> Source -> Add Folder

Choose the right folders which needs to be part of Build Path

In the above Screen shot src/main/resources needs to be removed from the build as it results in compilation error [wrong package ID]. Hence Include the Folder till src/main/resources .

I did try Build Path -> Exclude. This does not actually solve the problem. i.e though the RedX mark is cleared from the Eclipse, it will no more be right Java projects. I.e user may not be able to run JUnit Test cases/ debug etc.

But by including right folders, we can continue with as Java Project.

愚人国度 2024-09-26 21:19:04

由于资源文件夹中的文件很少更改,我建议将它们放入第二个项目(您可以在其中设置不同的警告选项),然后通过相对路径访问该文件(例如 ${basedir}/../special -tomcat)。

Since the files in the resource folder rarely change, I suggest to put them into a second project (where you can set different warning options) and then access that via a relative path (like ${basedir}/../special-tomcat).

紫南 2024-09-26 21:19:04

最好的方法是使用 Java 构建路径中的包含和排除模式选项。
例如,如果您想排除一个自动构建的项目:
1- 转到其属性 -> Java 构建路径 -> 源。
2- 展开“构建路径上的源文件夹:”区域中的文件夹
3-选择排除->编辑
4- 在排除模式中添加 **
注意:有关此模式的更多信息:包含和排除模式

The best approach is to use the Inclusion and Exclusion Patterns option in the Java Build Path.
For example if you want to exclude one project of being automatically build:
1- Go to its Properties->Java Build Path->Source.
2- Expand the folder in the "Source folders on the build path:" area
3- Select Exclude->Edit
4- In the exclusion patterns add **
Note: for more information on this patterns: Include and Exclusion Patterns

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文