Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 314924

Summary: Eclipse reports errors in exclude source files
Product: [Eclipse Project] JDT Reporter: Godmar Back <godmar>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, remy.suen
Version: 3.5.2   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
xml.bak should be ignored, but has errors flagged none

Description Godmar Back CLA 2010-05-28 13:50:14 EDT
Build Identifier: M20100211-1343

I asked Eclipse to exclude directories in my source folder. Yet, eclipse continues to examine, compile, and report errors in .java source files found in the excluded folders.

Please see the attached screenshot.

Reproducible: Always

Steps to Reproduce:
1. Create a project
2. Exclude a folder
3. Watch Eclipse ignore it
Comment 1 Godmar Back CLA 2010-05-28 13:51:48 EDT
Created attachment 170393 [details]
xml.bak should be ignored, but has errors flagged

As you can see, xml.bak has been excluded from the build path (the option "Build Path -> Use As Source Folder" is *ACTIVE*).  Yet, I'm seeing numerous error reports stemming from the folder.  How can this be?
Comment 2 Remy Suen CLA 2010-05-28 21:15:02 EDT
Platform/IDE is for generic IDE-ish bugs like the 'Problems' view. This looks more like an issue with the Java tooling.
Comment 3 Dani Megert CLA 2010-05-31 03:13:10 EDT
I assume that either
- the excluded folder has at least one folder which is on the build path. Note
  that you only exclude the folder from being built. Problem markers are always
  reported up to each folder and the containing project.
- you didn't clean + build
Comment 4 Godmar Back CLA 2010-05-31 08:02:10 EDT
By saying "you assume that the folder contains a subfolder that is not excluded," are you implying that in order to exclude a folder, I need to perform a manual recursive traversal and exclude every single folder?  In my case, that would be roughly 80 or so.

By saying "you didn't clean + build," are you saying that the functionality of excluding source folders depends on the user having "cleaned and built," but you do not consider this apparently nonsense requirement a flaw?

FWIW, from past experiences with Eclipse (where typically not even simple compiles work unless you clean, refresh, double clean and double refresh) I did all these things.  

I ended up shutting down eclipse, manually editing the .classpath file to ensure the correct exclusion path, then restarting it.  For your edification, exclude paths are recursive - it is not necessary to recursively exclude every single subfolder if one wishes to exclude a folder.
Comment 5 Dani Megert CLA 2010-05-31 08:23:28 EDT
>By saying "you didn't clean + build," are you saying that the functionality of
>excluding source folders depends on the user having "cleaned and built,"
It depends whether you have auto-build on or off. Obviously, if it is off, you are responsible to call the build command (clean is not strictly needed, it just makes sure you start from a clean point after changing the build path).

> For your edification, exclude paths are recursive
We implemented it, so we know what it does or does not. Whether it's recursive or not is irrelevant since the build path allows to exclude a folder but include some of its sub-folders. You didn't give detailed steps to reproduce the problem in comment 0 so I just had to make some guesses. Feel free to provide concrete steps to reproduce the problem and then reopen this bug.
Comment 6 Godmar Back CLA 2010-05-31 15:10:20 EDT
Not to be overly cranky, but let me just summarize my user experience.

Eclipse compiles files in xml.bak; I have no idea why. I've never added this folder to the source set. Judging by the error message (path name doesn't match class name), I realize that this is the problem. Therefore, I exclude the folder.

Eclipse ignores this and the errors don't go away.

Here's what I think should have happened.  If you make a decision anticipating a user's wishes (such as automatically including folders the user didn't ask you to compile), and if that decision turns out to be flat-out wrong (xml.bak shouldn't have been compiled), and if the user then takes remedial action (excluding xml.bak from the source path), then you should be as eager in undoing your wrong decision (and remove the errors you mistakenly flagged!) as were in making this wrong decision in the first place. 

Alternatively, and much preferred, don't include folders the user didn't ask you to compile files from in the build. This reminds me of an earlier bug I filed where Eclipse insisted that .SourceFile.java.swp was "a needed resource" and the project couldn't be compiled unless it was present.
Comment 7 Dani Megert CLA 2010-05-31 15:38:08 EDT
>Eclipse compiles files in xml.bak;
Does it really compile them (i.e. generate .class files) or do you only think it because of the error you see on the folder?

If you exclude a folder it should not compile the files in it. If you have steps that show otherwise then simply provide them as I already said before.