June 25, 2008

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.

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 *nix or windows with cygwin. It 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.
If the script doesn't work for you, drop me a comment. Feel free to improve it (you may drop me a comment too).

Update: the pastebin page expired (although I'd swear I checked the keep forever option), so I moved the script over to github.


4 comments:

Anonymous said...

Hi

Nice blog first of all...

About workspaces and projects...
I don't get the idea of having multiple workspaces. For me natural and easier is to have just one workspace.
It's particularly useful when one has for example projects which jars are dependencies to another project. You can easily switch to sourced-version of the dependant by using project instead of jar file (for deugging for example)

And you can avoid tons of projects using worksets and Mylyn...

Nice article though...

yossale said...

Great! i've been searching just for that!
Thanks :)

Dave Fry said...

Very useful. Thanks!

Aaronius said...

Thanks. I copied over the settings and it worked like I was hoping.