This Tip sounds very basic, but still: I get asked about this about once a week. So it must be something non-obvious in Eclipse then ;-): how to add existing files to an Eclipse project. As with many things in Eclipse, there is not a single way to do something. There are two basic ways to do this:
- Import
- Drag & Drop
- Copy & Paste
The first is the ‘official’ way in Eclipse, the other two are much faster and easier :-).
1. Import
To import one or multiple files, select the folder/project where I want to add the files, then use the menu File > Import:
Alternatively, I can use the context menu:
Then use General > File System:
In the next dialog, I can browse for the files and select them to be added:
2. Drag & Drop
While the ‘Import’ method is fine, I rarely use it: too many clicks! A easier way (at least under Windows) is to drag & drop the files from the Windows Explorer:
3. Copy & Paste
The third way is even easier:
- Select the files I want to add in the Explorer/File manager, and copy them (CTRL-C on Windows)
- Paste them in the project/folder in Eclipse (CTRL-V on Windows)
That last method does not advanced options like if I want to link to the files, see “Link to Files and Folders in Eclipse“, but is definitely the fastest and easiest way.
Happy Adding 🙂
Getting the files to the right place (see above works), but I am still struggling to add the source files to the makefile. I have been assuming the makefile is automatically generated – I can add them by hand, but if the file is autogenerated, the additions will be wiped out (I assume).
LikeLike
If you are using an managed-make project (this is e.g. the default in CodeWarrior, Kinetis Design Studio or if you using the Gnu ARM Eclipse plugins, then yes, the make file is automatically generated and your new files will be automatically added. If you are using a normal make file project (no managed-make), then you have to manage your make files by hand.
I hope this helps.
LikeLike