Eclipse Workspace Tips
Join the DZone community and get the full member experience.Join For Free
usually, one of the first things i see if i launch eclipse is this dialog:
actually, that ‘workspace’ thing is one of the most important things in eclipse to understand. to mess around it can cause a lot of pain. so i have collected some ‘lessons learned’ around workspaces.
the workspace .metadata folder
the workspace is where eclipse stores that .metadata folder:
in this folder, eclipse stores all the workspace settings or preferences i configure e.g. using the menu window > preferences .
sometimes that .metadata folder is named ‘framework’ too. e.g. if i’m are asked by eclipse to store some settings in the ‘frame work’ then this means it will be stored in the .metadata.
eclipse uses this folder as well to store internal files and data structures. and many plugins store their settings in here to. consider the content of this folder as a ‘black box’: so do not change it, do not touch it unless you *really* know what you are doing!
do not copy or move that folder. if you want to copy/share your workspace settings, then do *not* copy the .metadata folder, as typically you cannot use this folder on another machine or for another user. if you want to transfer/copy your settings, then see this post .
workspace and eclipse versions
as eclipse stores information in the .metadata workspace structure, the data/format might be different from version of eclipse to another (e.g. from one version of codewarrior to another). while using the same workspace with different versions of eclipse might work, it is *not* recommended. the eclipse community tries hard to keep things compatible, but using a different workspace for different eclipse versions is what i recommend.
i started to name my workspace(s) like ‘wsp_lecture_10.2′ or ‘wsp_lecture_10.3′ to show that i’m using it for a specific version of codewarrior.
workspace and projects
this leads to the question:
“do i have to duplicate then my projects if using with different versions of eclipse in parallel?”
the answer is ‘no’. because the workspace folder does *not* have to have the projects in it (as folders). they can, but it is not needed. for example i have different workspaces (“wsp_10.3″, “wsp_10.2″), but my projects are in the “projects” folder somewhere else on my disk. what i do is to import the projects into each workspace, keep the projects in their original folder location. the menu file > import > general > existing projects into workspace can be used, with ‘copy projects into workspace’ * unchecked *:
an easy trick is to drag&drop the project folders into eclipse: that’s much faster and simpler in my view than using above dialog.
tip: showing the current workspace in the title bar
using multiple workspaces can be confusing at some time. see this post how you can show the workspace in the application title:
processor expert has a special setting in the workspace pointing to its ‘data base’. that data base is inside the installation folder, in the mcu\processorexpert folder. if a launch eclipse and use a workspace from a different installation, i get a warning dialog:
processor expert workspace warning: current worksapce is configured to use data from another installation of processor expert.
that path setting of processor expert (pointing to the installation folder) is in my view the biggest argument to *not* share a workspace between different versions of eclipse.
pressing the ‘open preferences’ opens the settings, and with ‘restore defaults’ it will (after a restart of eclipse) use the new installation path:
that warning might not come up if using multiple installations of codewarrior. it seems that as long there is a valid path to a processor expert data base, the warning might not show up, and it will use that data base. that can lead to weird behaviour, so better check that the path in the workspace setting is pointing to the right folder.
workspace dialog on startup
remember that dialog at the beginning of this post? if i want to change if (and what) is shown at eclipse startup, then this is configured with the menu window > preferences > general > startup and shutdown :
in this dialog i can remove items from the list (e.g. if a workspace folder does not exist any more).
as eclipse stores a lot of information in the workspace .metadata, that folder can grow to a substantial size (several hundreds of mbytes, depending on usage and configuration). one reason is because eclipse stores local history and undo information into that .metadata folder.
just have a look at .metadata\.plugins\org.eclipse.core.resources\.history
so from time to time (especially if i think that eclipse is slowing down), i export my workspace settings ( file > export > general > preferences , see copy my workspace settings ) and re-import it again into the new workspace.
- eclipse stores all its workspace settings and files in the .metadata folder.
- never touch/copy/change/move the .metadata folder.
- use different workspaces for each eclipse version.
- store the projects outside of the workspace if you want to share them across different eclipse versions.
Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.