使用符号链接的 Eclipse 工作区/项目设置
我有以下简化的设置:
~/Development/Repositories/ProjectA-trunk
~/Development/Repositories/ProjectA-branch
~/Development/workspace
~/Development/workspace/ProjectA
ProjectA 是 ../Repositories/ProjectA-trunk 的符号链接。在理想的情况下,我能够将链接切换到指向 ../Repositories/ProjectA-branch,然后在 Eclipse 中刷新项目并在分支上工作。
在这个不幸的现实世界 Eclipse 中,即使最初导入现有项目时另有说明,也会解析符号链接并在“ProjectA”的“属性”>“资源”>“位置”中保留项目的绝对路径,在本例中为 ~/Development/存储库/ProjectA-trunk。因此,切换符号链接没有任何效果,因为 Eclipse 现在认为 ProjectA 位于 ~/Development/Repositories/ProjectA-trunk 而不是 ~/Development/Repositories/ProjectA。
有没有人有关于如何设置工作区以使与这样的分支一起工作的解决方案、解决方法或建议?
I have the following simplified setup:
~/Development/Repositories/ProjectA-trunk
~/Development/Repositories/ProjectA-branch
~/Development/workspace
~/Development/workspace/ProjectA
ProjectA is a symlink to ../Repositories/ProjectA-trunk. In an ideal world I'd be able to switch the link to point at ../Repositories/ProjectA-branch and then go refresh the project in Eclipse and be working on the branch.
In this unfortunate real world Eclipse, even though it says otherwise when importing the existing project initially, resolves the symlink and keeps the absolute path to the project in Properties>Resource>Location for "ProjectA", which is in this case ~/Development/Repositories/ProjectA-trunk. Therefore switching the symlink has no effect because Eclipse now thinks ProjectA lives at ~/Development/Repositories/ProjectA-trunk and not ~/Development/Repositories/ProjectA.
Does anybody have a solution or workaround or suggestion on how to set up your workspace to make working with branches like this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最初导入项目(假设
~/Development/workspace/ProjectA
当前不存在):mv ~/Development/Repositories/ProjectA-trunk ~/Development/workspace/ProjectA
>~/Development/workspace/ProjectA
导入 Eclipsemv ~/Development/workspace/ProjectA ~/Development/Repositories/ProjectA-trunk
ln -s ~/ Development/Repositories/ProjectA-trunk ~/Development/workspace/ProjectA
每当您想要更改分支时:
ln -Tfs $BRANCH ~/Development/workspace/ProjectA
To import the project initially (assuming
~/Development/workspace/ProjectA
does not currently exist):mv ~/Development/Repositories/ProjectA-trunk ~/Development/workspace/ProjectA
~/Development/workspace/ProjectA
into Eclipsemv ~/Development/workspace/ProjectA ~/Development/Repositories/ProjectA-trunk
ln -s ~/Development/Repositories/ProjectA-trunk ~/Development/workspace/ProjectA
Whenever you want to change the branch:
ln -Tfs $BRANCH ~/Development/workspace/ProjectA
您可以通过在现有工作区上创建存储库来完成同样的事情。 Eclipse 使用工作区中的 .metadata 文件夹来确定存在哪些项目。然后将您的分支放在同一目录中(例如使用 git)。每当您想要切换分支时,您都可以
git checkout my_branch
,然后在 Eclipse 中刷新。也就是说,不要使用link,使用
git
来管理同一目录下的分支。编辑:完整的过程是这样的。在 Eclipse 外部克隆存储库(因为如果它位于工作区中,导入会困扰您)。导入到您的工作区。删除工作区中的文件夹并将存储库克隆到你的工作区中。
You can accomplish the same thing by creating your repository on an already existing workspace. Eclipse uses the
.metadata
folder in the workspace to determine what projects exist. Then have your branches in the same directory (using git for example). Anytime you want to switch branches yougit checkout my_branch
and then refresh in Eclipse.In other words, don't use link, use
git
to manage the branches in the same directory.Edit: full procedure goes something like this. Clone the repo outside of Eclipse (because the import nags you if it's in your workspace). Import into your workspace. Delete the folder inside your workspace and clone the repo into your workspace.
符号链接设置适用于 Mac OS 和 Eclipse(Indigo 和 Juno)。
其中 foo 是指向我想要使用的任何工作副本的符号链接。
切换时,我
rm ~/prj/foo
和ln -s
将另一个工作副本复制到 foo。在 Eclipse 中刷新,它就会接受更改。这里的技巧是,我的项目仅部分使用 Java,即我有工作副本主文件夹 (foo),下面是 Java、Perl、Postgres 等。当我链接到主文件夹(即
~/Documents/workspace/TheProject -> ~/prj/foo
)时,Eclipse 会解析导入时的符号链接并将生成的路径存储在项目属性中。仅当我拥有指向项目中 Java 文件夹的符号链接 (~/Documents/workspace/TheProject -> ~/prj/foo/Java
) 时,Eclipse 才会保留符号链接。整个符号链接内容很有用当您有同一分支/主干的不同工作副本并且需要在它们之间切换时,Eclipse 无法处理相同的项目名称两次,因此我不想丢失我的工作副本更改。
The symlink setup works for me with Mac OS and Eclipse (Indigo and Juno).
where foo is a symlink to whatever working copy I want to use.
When switching, I
rm ~/prj/foo
andln -s
another working copy to foo. Refresh in Eclipse and it picks up the changes.The trick here was that my project is only partly in Java, i.e., I have the working copy main folder (foo) and below that Java, Perl, Postgres, and so on. When I link to the main folder (i.e.,
~/Documents/workspace/TheProject -> ~/prj/foo
), Eclipse resolves the symlinks on importing and stores the resulting path in the project properties. Only when I have the symlink to the Java folder in the project (~/Documents/workspace/TheProject -> ~/prj/foo/Java
, Eclipse preserves the symlinks.The whole symlink stuff is useful when you have different working copies of the same branch / trunk and need to switch between them. Eclipse cannot handle the same project name twice. I don't want to lose my working copy changes. Hence the symlink.