Create New Eclipse Workspace - With All Your Old Settings
It's all a matter of taste. Do you like to have just one workspace for all your projects, or do you prefer to have multiple separate workspaces?
Sure, the first way seems to be the official, supported. It should be easy to manage the workspace -- given the tools like working sets (and working set filters), mylyn and the ability to close projects.
But I still don't get it.
I hate when my workspace is overflowing with projects, I want to have as many workspaces as projects.
So I create new workspace and live happily ever after.
But wait -- all my settings are gone. All my carefully crafted custom templates, all my keybindings, my font settings, everything is gone.
It's all text, fortunately
Lucky us. All eclipse settings are saved as a plain text in the workspace directory. So if you want to create new workspace, but preserve your settings, I have two answers for you:
The short answer
All settings are stored in the .metadata/.plugins/org.eclipse.core.runtime/.settings directory. I mean -- all relevant settings. If you look into .metadata/.plugins directory there are many more directories with settings, but they are too project specific. I've walked trough these configuration files one by one, believe me, nothing useful lies hidden there.
So the short answer is: If you want to create a new eclipse workspace and preserve all your settings, simply copy the .metadata/.plugins/org.eclipse.core.runtime/.settings directory into your new workspace directory.
Do not copy other directories! There are project specific settings and since your old projects are left in your old workspace, the copied settings would not be valid and you would get some nasty exceptions at eclipse startup.
The long answer
Let the code do the talk for me.
I have created a (simple) shell script that automates new workspace creation. The downside is that it requires either a *nix shell or windows with cygwin. Nevertheless, you can always manually copy the .settings directory (see the short answer). The script has been tested by me, I and myself so it should work (most of the time).
To use it, save it somewhere, make it executable (chmod +x new-workspace.sh) and run it either in interactive mode
./new-workspace.sh -i
where it will ask you the details, or with paths to your workspaces (the new workspace directory will be created for you, just specify the path)
./new-workspace.sh old-workspace new-workspace
The script will create new workspace directory and copy the relevant settings from your old workspace.
If it doesn't work for you, drop me a comment. Feel free to improve it.
Update: the pastebin page expired (although I'd swear I checked the keep forever option), so I moved the script over to github.
- Login or register to post comments
- 5487 reads
- Flag as offensive
- Email this Story
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)







Comments
David Karr replied on Mon, 2008/06/30 - 11:35am
What risks are there when creating a new workspace with this that will be used with a different version of Eclipse than the original workspace?
Also now at Eclipse 3.4, there are now several different pieces that can be separately exported and imported in a new Eclipse 3.4 workspace, technically making this script less meaningful (although still a little more convenient). It's also unfortunate that those several pieces that Eclipse 3.4 can export and import still have to be done in different places.
Tomas Kramar replied on Tue, 2008/07/01 - 1:10am
I am using my 3.3 Eclipse created workspaces with 3.4 without any problems. The worst thing that can happen is that you get an exception at startup, but nothing worse.
Exporting and importing settings was possible even with 3.3, but as you said, it had to be done in several different places, making it very inconvenient and time consuming.
Looking at my 3.4 workspace -- the .settings directory is still there, with all relevant files, so the script will work even with 3.4.
maxwellmac99 replied on Tue, 2008/07/08 - 8:17am
Hi Tomas,
firsly thanks for the tip. I've been wondering how to do this for ages.
One problem though. I copied the file and then started Eclipse pointing to the new workspace. All the settings were there. However, all the original projects were included also, all in their original location.
Any ideas?
Thanks again,
Max
Tomas Kramar replied on Wed, 2008/07/09 - 1:26am
Hi Max,
thanks for your feedback.
I'm not sure what happened. Did the script copy all your old projects into new workspace (can you find the projects directories in the new workspace)? If not, then please send me a copy of the created workspace, I will have a look.
Either way, this will be better handled by email, so we do not spam here. You can find my address in the script.
maxwellmac99 replied on Wed, 2008/07/09 - 5:26am
in response to: kremso
Hi All,
sorry I was being a numpty. I had my -data command line option still pointing to the old workspace. Corrected that and it now works a treat!
Kind regds,
Max
k2col replied on Wed, 2008/07/09 - 1:25pm
I had some problems getting the script to work with cygwin after I saved the script in my editor with the default settings. I got it working though, by saving the script in "Unicode - ASCII Escaped" with "UNIX line Terminators".
Thanks for posting - it was very helpful
Tomas Kramar replied on Fri, 2008/07/11 - 12:37am
James Ervin replied on Mon, 2008/07/14 - 3:48pm
Can't you just export your preferences? The 'File > Export > Preferences' menu item will create a .epf file somewhere that can be imported into Eclipse when you are pointing at your new workspace.
Still the idea of just copying one directory has its appeal, I will keep this one in mind for future reference. Of course, I tend to do the whole one workspace to rule them all thing too.
Tomas Kramar replied on Tue, 2008/07/15 - 1:14am
in response to: jeervin
maxwellmac99 replied on Tue, 2008/07/15 - 3:15am
James,
just looking at this. Export preferences looks like it just does keys and JREs. For things like external tools, launch configurations, plugins, etc., we need something a bit deeper.
Cheers,
Max
James Ervin replied on Tue, 2008/07/15 - 1:05pm
in response to: maxwellmac99
You are right Max that it does not do everything, but it does a little more than that. It will preserve settings like key bindings and code formatters as well. Still like I said, I will keep this little tidbit in mind the next time I create a new workspace, that is for sure.
maxwellmac99 replied on Mon, 2008/08/04 - 4:38am
in response to: rwhansen
Hi Richard,
I don't have that option. I'm on 3.2.2. Is it in a later release?
Cheers,
Max