I have a C pro开发者_StackOverflow社区ject in Eclipse that stores its files in two directories at the same level along with a bunch of other stuff that I do not need to have in the project.
/path/
/code_I_want
/bad_stuff/
/more_code_i_want/
/huge_pile_of_other_code/
Edit: The source directory is a Clearcase VOB mount point so I can't control what ends up there.
- Create a new C project in Eclipse. You can give it its own directory at some arbitrary location in the filesystem, or you can point its folder at
code_I_want
ormore_code_i_want
. - Go under File, New, Folder. Click the Advanced section and click "Link to folder in the file system." This creates a virtual folder within your Eclipse project (similar to a symlink, if you're familiar with Linux / Unix) to whatever path you specify. Use this to make
code_I_want
and/ormore_code_i_want
into virtual subdirectories of your Eclipse project. - Notice the Variables button there under the Advanced section? That can be used to help create relative paths. (For example, each of our developers sets a per-user variable called APP to point to their local working copy, then the Eclipse project settings can be shared between developers regardless of where they keep their working copies.) To define variables, go under Windows, Preferences, General, Workspace, Linked Resources.
Edit: Or you can just create symlinks.
Try this:
Project > Properties > Java Build Path > Source > Add Folder
New --> File --> Source Directory or Folder.
If you don't want files in the project, don't import them into eclipse and eclipse won't/shouldn't display them.
This is an old question, but it came up in a Google search I had on the same topic, and I think there is a better answer now: Using Eclipse/CDT, you can now add the root /path/
provided in your example above which will automatically add the full tree to your Project Explorer. The source files in the code_i_want/
and more_code_i_want/
folders will automatically be included in your builds at this point.
In order to exclude the bad_stuff/
and huge_pile_of_other_code/
folders from your build (but not your Project Explorer tree in Eclipse, which can be handy), simply right-click on each folder in the Project Explorer and choose Resource Configurations->Exclude from build...
in the popup menu. The icon in Project Explorer will be updated to reflect the source files in this folder will no longer be included in the build.
Even better, Eclipse allows you to specify code that you want to include in some build configurations but not in others, so you can manage build-specific code in this manner.
精彩评论