104

We have a bunch of malformed XML files used in unit tests to check if our application can handle them.

Eclipse marks this XML files with errors, polluting the "problem view".

Is there a way to exclude a specific folder from Eclipse validators?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Serxipc
  • 6,639
  • 9
  • 40
  • 51

6 Answers6

93

In the Validation section of Window > Preferences you can add different rules in settings (...) column, you can add a "Folder or file name rule" in the Exclude Group for XML types.

63

This is what I do to exclude a folder from validation in a project. For me this works for javascript and other warnings/errors.

  • Right Click Folder
  • Click Resource, ResourceFilters
  • Click "Add"
  • Set the following Exclude All, Files and Folders, All Children, add an asterisk (*) to the File and Folder Attributes input field (highlighted in the image below)

Note: In Eclipse Indigo you have to Right click the folder and select properties and then select resource in the left navigation.

enter image description here

Thomas
  • 4,119
  • 2
  • 33
  • 49
Shanimal
  • 11,517
  • 7
  • 63
  • 76
  • 39
    This will exclude the folder from the resource tree, not only from validation. – Serxipc Mar 22 '12 at 11:50
  • 3
    I was trying to hide the resources from the validation and tree (too many files) so that's perfect to me – carlosvini Aug 20 '14 at 19:25
  • 4
    Another thing to note: it'll also exclude the filtered items from your app package if you use Eclipse to export your project (as a .war or whatever). – cjm Jun 30 '16 at 18:41
  • This does it, but you cant see the files at all now to browse them or look through them. A bit too much, but maybe someone needs this. – kiltek Jul 21 '17 at 13:00
20

With Eclipse 2018-12 in an Angular-Project, i was able to get rid of validation errors in the folders, npm generates (like node_modules), just by selecting a folder and check the "Derived" check mark under "Resource".

eclipse - ignore validation on folders by check the "Derived" check mark under "Resource"

After a Project -> Clean the Errors are gone.

Markus Pscheidt
  • 6,853
  • 5
  • 55
  • 76
hinneLinks
  • 3,673
  • 26
  • 40
  • 2
    Perfect! Can't believe how annoying it was! – Ragnar Dec 03 '19 at 11:35
  • 1
    If you are wondering aboutr the meaning of the option "Derived": It informs Eclipse that this folder contains generated files which are to be ignored for some operations; and one of these operations is checking for syntax errors. – user1364368 Jan 23 '20 at 08:48
  • This is essentailly the same as a [previous answer](https://stackoverflow.com/a/9809031/545127) – Raedwald Oct 06 '20 at 13:35
14
  1. Go to Window > Preference > Validation
  2. Find the type of validation you want to disable, for instance XML.
  3. Right-click it and select "Settings":

Eclipse validation

  1. In the "Exclude Group", click "Add rule", select "Folder or file name":

enter image description here

Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373
  • 3
    I had some problem adding a folder rules. The trick I used was to use "browse folder", select some random folder, click "ok" and then rename the folder name in the text box like I want. If I didn't do this, only file pattern was possible. – Jonatan Cloutier Apr 18 '17 at 00:11
  • This solved my issue. I wanted to ignore errors for a specific generated directory without removing it from my build path. This was the only answer that worked. +1 – Cardinal System May 13 '22 at 19:31
5

Note: I got here because I was searching for an easy way to exclude specific folders from validation in Eclipse. My answer does not work for the specific case detailed in the question (which is about hiding invalid XML files from validation).

How to exclude specific folders or files from validation in Eclipse?

When the folders is in the build path, and when the annoying issues are only warnings, there is a way that is straight forward:

  • Right Click Folder
  • Properties
  • Java Compiler
  • Check Ignore optional compile problems
  • Ok

The folders will still be validated, errors will be reported, but all the warnings will be ignored by Eclipse. For example, that's ideal for a folder of generated sources.

boumbh
  • 2,010
  • 1
  • 19
  • 21
2

you may also adjust the output/view side. So go to Show-Menu of Problem-View and filter Display only for selected Items. enter image description here

SLN
  • 51
  • 3