使用符号链接的 Eclipse 工作区/项目设置

发布于 2024-10-17 08:26:50 字数 632 浏览 10 评论 0原文

我有以下简化的设置:

~/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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧城烟雨 2024-10-24 08:26:50

最初导入项目(假设~/Development/workspace/ProjectA当前不存在):

  1. mv ~/Development/Repositories/ProjectA-trunk ~/Development/workspace/ProjectA >
  2. ~/Development/workspace/ProjectA 导入 Eclipse
  3. mv ~/Development/workspace/ProjectA ~/Development/Repositories/ProjectA-trunk
  4. ln -s ~/ Development/Repositories/ProjectA-trunk ~/Development/workspace/ProjectA
  5. 刷新 Eclipse

每当您想要更改分支时:

  1. ln -Tfs $BRANCH ~/Development/workspace/ProjectA
  2. 刷新 Eclipse

To import the project initially (assuming ~/Development/workspace/ProjectA does not currently exist):

  1. mv ~/Development/Repositories/ProjectA-trunk ~/Development/workspace/ProjectA
  2. Import ~/Development/workspace/ProjectA into Eclipse
  3. mv ~/Development/workspace/ProjectA ~/Development/Repositories/ProjectA-trunk
  4. ln -s ~/Development/Repositories/ProjectA-trunk ~/Development/workspace/ProjectA
  5. Refresh Eclipse

Whenever you want to change the branch:

  1. ln -Tfs $BRANCH ~/Development/workspace/ProjectA
  2. Refresh Eclipse
不知所踪 2024-10-24 08:26:50

您可以通过在现有工作区上创建存储库来完成同样的事情。 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 you git 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.

天赋异禀 2024-10-24 08:26:50

符号链接设置适用于 Mac OS 和 Eclipse(Indigo 和 Juno)。

robert@pferdeapfel:~> ls -l ~/Documents/workspace/
total 8.0K
lrwxr-xr-x 1 robert staff   33 Dec 27 14:05 TheProject -> /Users/robert/prj/foo/Java

其中 foo 是指向我想要使用的任何工作副本的符号链接。

robert@pferdeapfel:~> ls -ld ~/prj/foo
lrwxr-xr-x 1 robert staff 5 Dec 27 13:47 /Users/robert/prj/foo -> trunk

切换时,我 rm ~/prj/fooln -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).

robert@pferdeapfel:~> ls -l ~/Documents/workspace/
total 8.0K
lrwxr-xr-x 1 robert staff   33 Dec 27 14:05 TheProject -> /Users/robert/prj/foo/Java

where foo is a symlink to whatever working copy I want to use.

robert@pferdeapfel:~> ls -ld ~/prj/foo
lrwxr-xr-x 1 robert staff 5 Dec 27 13:47 /Users/robert/prj/foo -> trunk

When switching, I rm ~/prj/foo and ln -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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文