I admit that I have (a few? or not so few) bad habits: one of it is that usually I find a way to do things, and if that works, I stick with it. I know that there are other ways to do things, but hey, why bother? And sometimes a good friend asks an excellent question (are there any bad questions?), and this let me review the way I’m doing things. And here is such a thing: exporting and importing projects in Eclipse.
Archive Files with Drag & Drop
Here is how I usually move or copy a project to another machine:
- Find the project place on my hard disk. An easy way is to select the project folder and use the context menu with Show in Windows Explorer
- Zip that project into an archive file
- Delete from that archive file any derived resources (see Dissection of MCU10 Projects), as well remove all the version control information.
- Copy the archive file into the destination workspace and unzip it there
- Then drag&drop that folder into Eclipse: this will import that project into the workspace. Instead of the folder I simply can drag&drop as well the .project file
Note: Best if I drag&drop the project into the ‘CodeWarrior Projects’ View. This will not work if I drop it into the Processor Expert ‘Project Panel’ view.
Well, that works, and I really get used to that process. So why bother? Because there is actually a better way: to Export and Import.
The Export and Import Way
- I select one or more project and use the ‘Export’ context menu or File > Export. Here I select General > Archive File:
- In the ext dialog I can deselect files and folder. Additionally I need to specify the archive file. I could use Filter Types(e.g. to include *.c and *.h), but really what I wish is that this dialog would consider the ‘derived’ flags for files and folder, so I could deselect them easier.
- In the destination workspace, I use the menu File > Import:
And here is the stumbling point: I do not (!) select ‘Archive File’, but ‘Existing projects into Workspace‘. Yes, I have exported it as Archive File, but Importing an Archive File is importing an archive file inside a project, not (!) as a project. Yes, this is a usability quirk in Eclipse :-(.
- In the next dialog I can choose the archive file and make adjustments which project I want to import. I note that it will automatically copy the projects into my workspace.
- Pressing Finish, and my projects get imported.
I’m using combinations of both ways: the archive file produced by the Export is not different from an archive file I create with my WinZip archive utility (or any other tool like this one). For both export ways I need to manually remove what I do not want in the archive file. I wish there would be better support for this. But for importing projects the Import functionality is really good, as it avoids the copy/extract/drag&drop way: I can go through two dialogs, and that’s it.
Happy Export-Import 🙂
PS: Thanks to Mark Ruthenbeck having me considering more the Export/Import way!