How can I stop Eclipse warning about target folder's contents?

此生再无相见时 提交于 2019-12-19 15:16:22

问题


I'm getting loads of warnings from generated files in my target folder (e.g. Java code generated from XSDs or surefire reports) that I can't fix, and it's hiding proper warnings in my source code.

Does anyone know of a way to tell Eclipse not to display warnings in certain folders, or just the "Derived" or target folders?

I've only been able to find the following two "almost" solutions:

  1. The filter in the "Problems" view allows you to hide warnings containing (or not containing) a specific String in their description, but not part of their path or resource (file). Even if you could, this wouldn't be an ideal solution as the warnings would still be displayed on the project in the package explorer, hiding potential real warnings.
  2. With the latest Eclipse version (Juno / 4.2) in the "Java Build Path" settings under the "Source" tab, you can "ignore optional compile problems" from each source folder. But this obviously doesn't work for cases where the folders aren't source folders (like the surefire reports). It does however fix one specific problem with warnings about generated sources, but might not in others, where the sources aren't (can't be) included as source.

It would just be nice if there was a way to tell eclipse not to display warnings about things in the target folder altogether, as it's often not very useful and might hide actual problems.

Cheers,
    Svend.


回答1:


It turns out you can do this fairly simply (at least in Eclipse Kepler).

Open up the Preferences panel, either for Eclipse as a whole or for the project. Select the Validation pane (if you're using the project preferences panel, you may need to enable project-specific settings). Now go to the validator that's causing you problems (in my case, it was the HTML validator, but it depends on what you're doing) and click the button to edit its settings, which pops up another dialog.

In this dialog you want to make sure that there is an Exclude Group that excludes Folder: target. If there's no exclude group at all, add one with the button on the right. Then select the exclude group and Add Rule… to bring up another dialog/wizard. You want to add a Folder or file name, and in the next step pick the target folder to exclude (using the Browse Folder… button) and keeping the checkbox for using just the simple filename checked. If you're adding a global rule, it doesn't matter which target folder you pick.

The OK/Apply back out of all the dialogs to apply the change you've made (or maybe add more exclusion rules). You'll need a rebuild so that the rule change is applied correctly, but that's straight-forward.




回答2:


Folders that are not source folders are not compiled by Eclipse. So you should not have Java error/warning for those.

For source folder, you already have the solution ('Ignore optional compile problems' parameter).



来源:https://stackoverflow.com/questions/11757507/how-can-i-stop-eclipse-warning-about-target-folders-contents

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!