Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 803
Svend Hansen Avatar asked Aug 01 '12 10:08

Svend Hansen


People also ask

How do I ignore target folder in eclipse?

Mark the "target" folders as "derived" resource from the properties screen of those folders (this option is next to read only and archive property). In the quick search ( Ctrl + Shift + R ) screen press the arrow in the top right corner and untick "Show derived resources".

How can I see warnings in eclipse?

For the Target Management Project, we recommend enabling the following compiler warnings in JDT (Window > Preferences > Java > Compiler > Errors/Warnings and Javadoc). Settings that differ from the JDT default are marked in bold.

How to move a package in Eclipse?

Right-click the package you want to move, and select " Refactor/Rename..." -- NOT " Move "! Modify the name of the package to reflect its desired new position in the package hierarchy, e.g. Prepend any new parent package name(s) if you are moving the package to downwards in the package hierarchy.


1 Answers

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.

like image 129
Donal Fellows Avatar answered Sep 18 '22 16:09

Donal Fellows