Why does Eclipse builds source in non-source folder?
I have just set up a new Eclipse Java project. In this project I included a folder called external
, holding thi开发者_JAVA技巧ngs like jars, and the source of these jars. The only source folder in the project is the empty src/
folder, neither the external/
folder nor any subdirectories of the external/
folder are marked as source folders.
Nonetheless Eclipse chooses to compile (and choke on) the source files located beneath the external/
folder. Does anybody know why it would do that, and how to stop it from attempting to compile these files?
Update
The file hierarchy is:
project/
src/ (Marked as source folder)
bin/
external/ (Linked folder, not marked as source folder)
The external/
folder is created by right-clicking on the project, choosing New -> Folder, clicking advanced and choosing "Link to alternate location". And then I have provided a relative path to a folder outside of my source hierarchy.
I have this external/
folder configured in several other projects exactly like this, without any problems.
Solution
The code was not compiled at all, Eclipse had marked warnings and errors in the source files in the external/
directory, and therefore I assumed Eclipse tried to compile these sources. However, the warnings/errors were added by my checkstyle plugin in Eclipse. Which by default parses source files in all directories in projects for which it is enabled.
Thus the solution is to instruct checkstyle only to analyse sources in folders that are marked at source folders.
Thanks for all the help.
You can toggle which folders contain code for Eclipse to compile by right clicking on the folder, highlighting Build Path, then selecting "Use as Source Folder" or "Remove from Build Path". Any folder you remove from the Build Path will just show any .java source as a text file.
Remember that Eclipse's file system is not synchronized with your actual file system. To let Eclipse know that a folder exists in your project directory you have to click and drag it into your projects view in Eclipse.
精彩评论