eclipse workspaces sync settings - what to sync?
Asked Answered
G

3

14

I know it has come up time and again but my specific question is : I have multiple workspaces using the wpt, cdt and jdt extensions (and others). I want to create hard links (I am on windows) from all my workspaces to a subset of settings files that govern things like shortcuts, workspace preferences etc. This way when I, for instance, change a shortcut in one workspace the change will propagate to all other workspaces. Problem is the .metadata/.plugins folder is a complete mess (I believe the settings are all there). For instance I know that I have to link the files :

<workspace>\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.core.prefs
<workspace>\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.ui.prefs

I believe I should not try to link the whole .metadata/.plugins folder as it contains workspace-specific data.

  • Would it be safe and enough to hardlink the \.metadata\.plugins\org.eclipse.core.runtime\.settings directory ?

  • Can someone point me to some documentation as to what are all those.index and .dat binary files inside \.metadata\.plugins\ ?

  • If this is not possible I would appreciate at least a reference for the various .prefs files inside \.metadata\.plugins\*\.settings directories, especially the .metadata\.plugins\org.eclipse.core.runtime\.settings one

Thanks

Gaud answered 11/11, 2012 at 18:34 Comment(0)
G
8

Alright, what I did (eclipse juno on windows 7) was :

  • Created a new eclipse workspace, say test, run it and just shut it down

  • Made it into a git repo

  • Committed the files that were created by eclipse along with this .gitignore :

    # binary files
    *.dat
    *.tree
    *.index
    .metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache
    .metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache
    .metadata/.mylyn/repositories.xml.zip
    *.resources
    
    # logs
    *.log
    
    .metadata/.lock
    
    # later additions
    .metadata/.plugins/org.eclipse.pde.core/.cache/
    *.running
    
  • Switched to a new branch

    Fired up one of my workspaces, exported ALL the settings then fired up the test workspace and imported them. Compared the .metadata/ dirs of the workspaces with the help of Beyond Compare. The .metadata\.plugins\org.eclipse.core.runtime\.settings\ folders were identical apart from the org.eclipse.ui.workbench.prefs file - but the differences did not seem important (i.e. workspace specific). On shutting down the workspace the file org.eclipse.jdt.launching.prefs was also modified. Switched to master and repeated for the rest of my workspaces.


There were complications - so for instance :

  • the file org.eclipse.jdt.core.prefs was present in the test workspace while in the original workspace (from were I imported) there was the (binary identical) org.eclipse.jdt.core.prefs.bak.

  • The file org.eclipse.pde.core.prefs was not imported

  • The files org.eclipse.jdt.launching.prefs and org.eclipse.ui.workbench.prefs differ.

After the fifth workspace I was settled that the files

.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml 
.metadata/.plugins/org.eclipse.jdt.launching/.install.xml

are created when settings are imported (in a new workspace), that the file .metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.pde.core.prefs is not exported/imported, that the file .settings\org.eclipse.ui.workbench.prefs is merged on import (namely the *ENABLED_DECORATORS* var stays as is) and the org.eclipse.jdt.launching.prefs is edited on shutting eclipse down.

There are further complications like files containing project references :

  • For instance, the file org.eclipse.wst.sse.core.prefs contains project names from the workspace - I reported this as a bug (it was fixed really quick !).

  • CDT creates a bunch of files like :

    .settings/org.eclipse.cdt.core.prj-<projectName>.prefs
    .settings/org.eclipse.cdt.ui.prj-<projectName>.prefs
    

which are blindly synced on export/import. This actually is a much more complicated case than the previous one - reported it also.

In fact, whatever you have in the .settings dir will be copied along (I guess as long as it has a .prefs suffix). This warrants another bug report.

Similar situations are encountered in other files which contain workspace specific options - like in org.eclipse.ui.ide.prefs which contains references to the working sets - which are rather workspace specific - or in org.eclipse.ui.browser.prefs which contains the internalWebBrowserHistory - which is usually also workspace specific.


Anyway I decided to go for the hard links - so I normalized my preferences (it would be much much easier to start with a fresh workspace) and copied all the settings apart from org.eclipse.wst.sse.core.prefs, the cdt ones and the org.eclipse.pde.core.prefs (as for some reason it was not imported. The org.eclipse.ui.workbench.prefs which is rather special contains also the shortcuts). Then I run :

REM move_settings.bat
set SETTINGS_DIR=C:\path\to\tempalte\workspace\.metadata\.plugins\org.eclipse.core.runtime\.settings
set WORKSPACE_SETTINGS_DIR=C:\path\to\actual\workspace\.metadata\.plugins\org.eclipse.core.runtime\.settings
mkdir %WORKSPACE_SETTINGS_DIR%\zBackups
pause
FOR /F %%G IN ('DIR^ %%SETTINGS_DIR%%^ /b') DO (
    move %WORKSPACE_SETTINGS_DIR%\%%G %WORKSPACE_SETTINGS_DIR%\zBackups
    mklink /H %WORKSPACE_SETTINGS_DIR%\%%G %SETTINGS_DIR%\%%G
)
pause

for my workspaces.

And guess what : eclipse breaks hard links. I tried soft links (mklink %WORKSPACE_SETTINGS_DIR%\%%G %SETTINGS_DIR%\%%G) but no joy either.

Finally

I had to hard link (junction) the whole settings dir (along with all the problematic files I mentioned) - this is really not a solution. One of these days the situation must be addressed. Anyway here's the .bat I used :

:: Change to the directory that this batch file is in
:: NB: it must be invoked with a full path!
:: run the bat from the dir you want to backup your prefs to
for /f %%i in ("%0") do set curpath=%%~dpi
cd /d %curpath%

set WORKSPACES=javaEE\ javaSE\ c++\ python\ android\

set TEMPLATE_WORKSPACE=name_of_the_template_workspace\
set WORKSPACES_DIR=C:\Dropbox\eclipse_workspaces\
set SETTINGS_DIR=.metadata\.plugins\org.eclipse.core.runtime\.settings
REM set SETTINGS_DIR=.metadata\.plugins\org.eclipse.core.runtime\.settings\ WONT DO
set TEMPLATE_SETTINGS_DIR=%WORKSPACES_DIR%%TEMPLATE_WORKSPACE%%SETTINGS_DIR%

for %%G in (%WORKSPACES%) do (call :subroutine_needed %%G)
GOTO :eof

:subroutine_needed
    set WORKSPACE=%1
    set WORKSPACE_SETTINGS_DIR=%WORKSPACES_DIR%%WORKSPACE%%SETTINGS_DIR%
    set BACKUP_DIR=%CD%\zBackups\%WORKSPACE%
    mkdir %BACKUP_DIR%
    pause

    move %WORKSPACE_SETTINGS_DIR% %BACKUP_DIR%
    pause

    junction  %WORKSPACE_SETTINGS_DIR% %TEMPLATE_SETTINGS_DIR%
    pause

I'll update this post as needed

Gaud answered 25/11, 2012 at 2:12 Comment(1)
Thanks so much for sharing.Faludi
O
6

You can also have a look to workspace mechanic, a small plugin developed by google : http://code.google.com/a/eclipselabs.org/p/workspacemechanic/

UPDATE 28/11/12

So as far I understand, you need to keep in sync some plugins preferences.

The wiki explains it quite well. The steps I recommend you are the following:

With that you should be able to deal with syncing your workspace preferences.

Bonus: I like to put workspace mechanic preferences on dropbox to share it between team members and/or between my computers you can find a small how-to here : https://gist.github.com/3090900

Hope this helps.

Regards

Oni answered 27/11, 2012 at 23:9 Comment(0)
B
4

It's a pity that there still have to be workarounds for that.. I made similar steps as you but I first tried to hardlink and then did the git repository.

For me the git repository is the better option since I want to sync my workspace over multiple work stations. So for all the people that are still looking for a solution, I just started like you:

  • Create a clean workspace
  • Create git-Repo in .metadata
  • Restart Eclipse and see what changes
  • Create another workspace and see what changes
  • and so on ..

So far I managed to have a .gitignore containing all stuff that is not needed or unimportant. My workspace is still not 100% portable but nearly..

What I have to do when I start a new Eclipse workspace is just a git clone that's simple. The shortcoming is that there are some settings that aren't tracked. These are mainly GUI settings which almost ever containg also workspace specific settings.

So using this .gitignore you can have a manually synched workspace which works for most of the settings. But it needs to be maintained..

/.lock
*.log
*.index
/.plugins/org.eclipse.core.resources/.projects
/.plugins/org.eclipse.epp.usagedata.recording
/.plugins/org.eclipse.core.resources/.history
/.plugins/org.eclipse.ltk.core.refactoring/.refactorings
/.mylyn
/.plugins/org.eclipse.core.resources/.root/
/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources
/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs
/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.usagedata.recording.prefs
/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs
/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.sse.core.prefs
/.plugins/org.eclipse.jdt.core/
/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml
/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml
/.plugins/org.eclipse.jdt.ui/jdt-images/
/.plugins/org.eclipse.ui.workbench/workingsets.xml
/.plugins/org.eclipse.wb.discovery.core/
/.plugins/org.eclipse.wb.core/
/.plugins/org.eclipse.wst.internet.cache/cache.xml
/.plugins/org.eclipse.team.ui/syncParticipants.xml
/.plugins/org.eclipse.team.cvs.core/.running
/.plugins/org.eclipse.ui.workbench/workbench.xml
/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.ui.prefs
/.plugins/org.eclipse.m2e.core/nexus/
/.plugins/org.eclipse.m2e.core/workspaceState.ser
/.plugins/org.eclipse.debug.core/.launches/
/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml
/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.java.ui.prefs
dialog_settings.xml
/.plugins/org.eclipse.core.resources
/.plugins/org.eclipse.recommenders.rcp
/.plugins/org.eclipse.e4.workbench/workbench.xmi
/.plugins/org.eclipse.recommenders.completion.rcp.calls
/.plugins/org.eclipse.recommenders.completion.rcp.overrides
/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs
/.plugins/org.eclipse.wst.sse.core

My hint is, that you have a look at what changes after each shutdown of eclipse. This is what helped me creating this gitignore file and it works better than a plugin.

Begay answered 8/8, 2013 at 11:27 Comment(2)
Interesting ! will look at it more closely when I have more timeGaud
It is July 2021 now and I got here in search for a solution that should be as easy as vscode's. :-( Am I missing something?Yung

© 2022 - 2024 — McMap. All rights reserved.