Exporting and Importing Projects in Eclipse

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:

  1. 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
  2. Zip that project into an archive file
  3. Delete from that archive file any derived resources (see Dissection of MCU10 Projects), as well remove all the version control information.
  4. Copy the archive file into the destination workspace and unzip it there
  5. 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

  1. I select one or more project and use the ‘Export’ context menu or File > Export. Here I select General > Archive File:

    Export Project as Archive File

    Export Project as Archive File

  2. 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.

    Archive File Settings

    Archive File Settings

  3. In the destination workspace, I use the menu File > Import:
    Import Dialog to Import a Project

    Import Dialog to Import a Project

    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 :-(.

  4. 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.

    Import Archive Projects

    Import Archive Projects

  5. Pressing Finish, and my projects get imported.

Summary

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!

15 thoughts on “Exporting and Importing Projects in Eclipse

  1. I have a question for you that I could really use some help with. I have tried to use this procedure to import and export projects between two installations of Codewarrior for MCU V10.2 (Eclipse) on different computers (both windows). When I clean and rebuild the project on the pc I transfer the project to, it will only build the last configuration that was used (FLASH OR RAM). I develop by using RAM most of the time, then deploy by programming to the FLASH, so I really need these two configurations. When I try to build the nonworking of the two configs, I get the following error (for example):

    E:\CW MCU v10.2\gnu\bin\mingw32-make -j16 all
    mingw32-make: *** No rule to make target `../Project_Settings/Linker_Files/MCF52259_Internal_Flash.lcf’, needed by `PATH_PLAYER_6_20_12.elf’. Stop.

    The one workaround I have is to build the other config on the other PC and copy to file “MCF52259_Internal_Flash.lcf” or “MCF52259_Internal_Ram.lcf” (depending upon which one it’s missing) to the “/Project_Settings/Linker_Files/” folder on the PC I’ve transferred the project to. Have you tried building the “other” configuration once you’ve moved the file?

    Thank You,

    Cory

    Like

    • I have not had this kind of problem, and my projects sometimes contain as well a ‘RAM’ and a ‘Flash’ configuration. The “no rule to make target” means that this .lcf file mentioned in the error messages does not exist (see https://mcuoneclipse.wordpress.com/2012/03/12/no-rule-to-make-target/).
      Is this project a Processor Expert one? If yes, this means that usually the .lcf file is generated. Then your error message indicates that the .lcf file has not yet been generated, and is missing.
      Other hints:
      if you import a project, make sure you do a ‘clean’ (menu Project > Clean). You need to do this for every configuration (Ram, Flash).

      I hope this helps.
      Erich

      Like

  2. Have you done any importing of classic projects? In 10.1, you could do this through the import menu. Now in 10.3, it seems that they have removed the option. Is there another way to do this, or have they just done away with this?

    Like

    • Yes, that option is gone in 10.3. And I think for good reasons. That importer only worked for very simple projects. As soon as you have a little bit more complex project, the result was not what I expected, or compilation failed. It is much easier to simply create a new project with the wizard for the desired architecture, and then adding the source files to the project. No wizard needed for something like this.

      Like

  3. I’m trying the importing the Freedom_Shell.zip (internally dated 12/28/2012) with KDS 1.1.0 and its having problems. Then I try and bring up the component inspector and it has a java.lang.NullPointerException
    Really appreciate you publishing the code though.

    Like

  4. In step #2, how do you deal with the warning message:

    “Some of the selected projects have build settings that have file dependencies outside of the project directory. Exporting those projects will cause those settings to become invalid.”

    ?

    I know I have some absolute paths occurring in some of the .metadata files, but do I need to manually edit those files outside of Eclipse and replace each occurrence of such path?

    Thanks

    Like

    • Hi Barak,
      you don’t need to worry about the .metadata content: this is used internally to Eclipse only. But if your projects are using project relative path settings, then if you use these projects in a different workspace, you need to make sure that the settings and structure match what you have in the original project. There is no ‘silver bullet’: this always depends how you (or someone else) has architected the project structure and references.

      Like

      • The CW isn’t very friendly when it comes to projects and workspaces.
        I had to port a project located in drive E on my PC, to a different PC which had no E.
        I ended up mapping drive E on that other PC, which seemed to be faster than trying to figure out what I might have “mis-architected” in the project.

        Thank you for your help!

        Like

  5. Hello Erich,

    Because of some reasons, I have to move my whole toolchain from CW to Eclipse.
    Please tell me how to do it? I am using ARM Cortex M4 based MCU, gcc compiler and Multilink Universal P&E for debugging.

    Like

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.