eclipse工作区同步设置 - 要同步? [英] eclipse workspaces sync settings - what to sync?

查看:103
本文介绍了eclipse工作区同步设置 - 要同步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道它已经来了,但我的具体问题是:我有多个工作区使用wpt,cdt和jdt扩展(和其他)。我想从我所有的工作区创建硬链接(我在Windows上)到一些控制诸如快捷键,工作区偏好等的设置文件的子集。例如,当我更改一个工作区中的快捷方式时,更改将会传播到所有其他工作区。问题是.metadata / .plugins文件夹是一个完整的混乱(我相信设置都在那里)。例如,我知道我必须链接文件:

 < 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

我相信我不应该尝试链接整个.metadata / .plugins文件夹,因为它包含工作区特定的数据。




  • 是否安全和足够硬链接 \.metadata\.plugins\org.eclipse.core.runtime\.settings 目录?


  • 有人可以指出一些有关这些 .index .dat 中的二进制文件\.metadata\.plugins\

    / li>
  • 如果这不可能,我至少会欣赏各种 .prefs 文件内 \.metadata\.plugins\ * \.settings 目录,特别是 .metadata\.plugins\org.eclipse.core.runtime\.settings one




谢谢

解决方案

好吧,我做了什么(eclipse juno在windows 7上)是:




  • 创建一个新的eclipse工作区,说 test ,运行并关闭它


  • 将其变成git repo


  • 提交由eclipse创建的文件连同这个.gitignore:

     #二进制文件
    * .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 added
    .metadata / .plugins / org。 eclipse.pde.core / .cache /
    * .running


  • 切换到一个新的分支



    激活了我的一个工作区,导出所有设置,然后启动了测试工作区并导入他们。在Beyond Compare的帮助下比较工作区的.metadata / dirs。 .metadata\.plugins\org.eclipse.core.runtime\.settings\ 文件夹与 org.eclipse相同.ui.workbench.prefs 文件 - 但差异似乎不重要(即工作区特定)。关闭工作区时,文件 org.eclipse.jdt.launching.prefs 也被修改。







有并发症 - 例如:




  • 文件 org.eclipse.jdt.core.prefs 存在于测试工作区中,而在原始工作区(从我导入)中有(二进制相同) org.eclipse.jdt.core.prefs.bak


  • 文件 org.eclipse.pde.core.prefs 未导入


  • 文件 org.eclipse.jdt.launching.prefs org.eclipse.ui。 workbench.prefs 不同。




第五个工作区后,我确定文件

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

是在导入设置时创建的新工作区),文件 .metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.pde.core.prefs 未导出/导入,文件 .settings\org.eclipse.ui.workbench.prefs 在导入时合并(即* ENABLED_DECORATORS * var保持原样),并且在关闭日食时编辑 org.eclipse.jdt.launching.prefs



还有进一步的复杂性ns包含项目引用的文件:




  • 例如,文件 org.eclipse.wst.sse .core.prefs 包含工作区中的项目名称 - 我将其报告为 bug (它固定得很快!)。


  • CDT创建一堆文件,如:

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




在导出/导入时被盲目同步。这实际上比以前更复杂 - 报告它也



事实上,无论您在 .settings 目录中的任何内容都将被复制(我想长久以来因为它有一个 .prefs 后缀)。另外还有一个错误报告。



在包含工作区特定选项的其他文件中遇到类似的情况,如 org.eclipse.ui.ide。 prefs ,其中包含对工作集的引用 - 这些工作原理相当于工作区 - 或者 org.eclipse.ui.browser.prefs ,其中包含internalWebBrowserHistory - 通常也是工作区特定的。






无论如何我决定去硬链接 - 所以我对我的偏好进行了归一化从新开发的工作区开始会变得更加容易),并将所有设置从 org.eclipse.wst.sse.core.prefs cdt 一个和 org.eclipse.pde.core.prefs (由于某些原因它没有导入。 org.eclipse.ui.workbench.prefs 这是相当特别的还包含快捷方式)。然后我运行:

  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

暂停

为我的工作区。



并且猜测:eclipse打破硬链接。我试过软链接( mklink%WORKSPACE_SETTINGS_DIR%\ %% G%SETTINGS_DIR%\ %% G ),但没有喜悦。



最后



我不得不硬链接(连接)整个设置目录(以及我提到的所有有问题的文件) - 这真的不是解。其中一天必须解决这个情况。无论如何,这里是我使用的 .bat

  ::更改到此批处理文件在
:: NB中的目录:必须使用完整路径调用!
::从您想要备份您的预制的目录中的蝙蝠运行到
for / f %% i(%0)do set curpath = %%〜dpi
cd / d%curpath%

设置WORKSPACES = javaEE\ javaSE\ c ++ \ python\ android\

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

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

:subroutine_needed
set WORKSPACE =%1
set WORKSPACE_SETTINGS_DIR =%WORKSPACES_DIR %% WORKSPACE% %SETTINGS_DIR%
设置BACKUP_DIR =%CD%\zBackups\%WORKSPACE%
mkdir%BACKUP_DIR%
暂停

move%WORKSPACE_ SETTINGS_DIR%%BACKUP_DIR%
暂停

结%WORKSPACE_SETTINGS_DIR%%TEMPLATE_SETTINGS_DIR%
暂停

我将根据需要更新此帖子


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

解决方案

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

这篇关于eclipse工作区同步设置 - 要同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆