Eclipse,导入项目但不复制
我使用 Linux 作为主要操作系统,并且还必须在带有 Eclipse 3.7 的 Windows 虚拟机上工作。
我们正在使用 subversion,但对于 Linux,我很高兴将 git-svn 与 Emacs+magit 一起使用,效果很好。 所以我希望能够在两个操作系统上处理相同的代码,并且只在 Linux 上进行真正的版本控制管理。
所以我有以下想法:
1.与virtualbox共享目录
2. 创建指向共享目录的项目
这不行,因为愚蠢的东西想要复制所有内容。 因此,我尝试使用虚拟文件夹,这似乎是个好主意,但现在某些脚本严重失败,因为它们找不到硬编码路径。
所以我不知道该尝试什么,有什么想法吗?
编辑:
我在上次编辑中的最后一次尝试不起作用,所以我有一个更简单的问题。 给定 git/svn/whatever 存储库签出,为什么我不能简单地告诉 Eclipse 创建一个项目而不接触文件?
Eclipse 在那个位置创建它的 .project 有这么难吗?
由于显然没有“受支持”的方法来做到这一点,是否有任何解决方法?
I use Linux as primary operating system and I also have to work on a Windows virtual machine with Eclipse 3.7.
We're working with subversion but with Linux I'm happily using git-svn with Emacs+magit, which works great.
So I would like to be able to work on the same code from both OS, and only do the real version control management on Linux.
So I had the following thought:
1. share the directory with virtualbox
2. create the projects pointing to the shared directory
Well that doesn't work, because the dumb thing wants to copy everything.
So I tried to use virtual folders which seemed a good idea, but now some scripts are badly failing because they don't find the hard-coded paths.
So I don't know anymore what to try, any idea?
EDIT:
My last attempt in the last edit would not work, so I have a simpler question.
Given a git/svn/whatever repository checkout, why can't I simply tell to Eclipse create a project there without touching the files?
Is it so hard for Eclipse to create it's .project in that position?
And since there is clearly no "supported" way to do it, is there maybe any workaround?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据我的经验,阶段如下(使用 Indigo 版本):
1.新建空项目
2.点击文件->导入->文件系统
3.在导入窗口导入文件系统,勾选你想要的文件到新建的工程文件夹中
4. 单击导入窗口中的“高级”,然后勾选“在工作区中创建链接”。
新项目应包含指向原始目录的链接。
From my experience, the stages are the following (using Indigo version):
1. Create new empty project
2. Click File->import->file system
3. in the import window import file system, check the files you want into the new project folder
4. Click on advanced in the import window and tick "create links in workspace"
The new project should contain links to the original directory.
Eclipse 在其工作区中修改并编译源代码。工作区的第一级是项目目录,+ .metadata,仅在该工作区实例本地。传统上,工作区包含它所处理的项目。
Eclipse 还支持 2 种链接模式。其一,当您在工作区中创建项目时,您为其提供了文件系统上其他位置的绝对路径。例如,如果您在 git 存储库中有 eclipse 项目,这会很方便。
在另一种模式下,您在本地工作区中创建项目。然后,将文件夹(源、资源等)链接到文件系统上的其他位置。这对于不想在 SCM 中保存 Eclipse 特定文件(.project、.classpath 等)的项目非常有用。
您必须在每个操作系统上创建不同的工作区(没有办法解决这个问题)。但是您可以在每个工作区中创建项目并链接到公共位置(我不推荐这样做,但这是可行的)。
Eclipse modifies and compiles source in its workspace. The first level of the workspace is the project directories, + a .metadata which is local only to that workspace instance. Traditionally, the workspace contains the projects it works on.
Eclipse also supports 2 linked modes. In one, when you create the project in the workspace you give it an absolute path to somewhere else on the file system. This is handy if you have eclipse projects in a git repo, for example.
In the other mode, you create the project in your workspace locally. Then you link your folders (source, resources, whatever) to somewhere else on the filesystem. This is useful for projects that don't want to save the eclipse specific files (.project, .classpath, etc) in their SCM.
You have to create a different workspace on each OS (there's no way around that). But you could create the projects in each workspace and link to the common location (I don't recommend it, but it would be do-able).
同样的问题在这里终于得到了解决方案!
1)克隆您的存储库,但不直接克隆到您的工作区,在我的例子中,我使用workspace2而不是工作区。
2)在eclipse上,导入workspace2上的所有项目,但不要标记“复制文件到workspace”,所以源代码留在workspace2上。
3)在 git 上,您将看到 project.options 文件(仅文件日期发生更改)和 .path 文件(某些行更改了顺序)中出现了更改。由于所有这些都是不相关的更改,因此重置本地分支并丢弃这些更改。
就这样,git 没有看到更多的变化,并且 eclipse 正确打开文件!
我遇到了一个奇怪的问题,值得在这里评论:导入后,我转到“git gui”查看更改,第一个更改的文件是“project.options”文件,该文件只更改了日期,但差异是空的(因为内容没有变化)。 git 上有一个错误,使 git gui 进入无限循环:当它检测到文件上的更改并且 diff 为空时,会执行重新扫描,然后检测到相同的更改并进入重新扫描循环。
有一个补丁可以解决这个问题,但更容易的是在唯一的文件上添加一个愚蠢的评论(不在所有的project.options中),然后“git gui”再次高兴,我可以重置分支上的更改。
Same problem here and finally got a solution!
1) clone your repo but not directly to your workspace, in my case I used workspace2 instead of workspace.
2) On eclipse, import all the projects on workspace2, but don't mark the "copy files to workspace", so the source code is left on workspace2.
3) On git you will see changes appeared, on project.options files (only file date is changed) and in .path files (some lines changed its order). As all of them are irrelevant changes, reset the local branch discarding those changes.
Thats all, git sees no more changes and eclipse open the files properly!
I ran into a weird problem worth commenting here: after importing i went to "git gui" to see changes, and the first file changed was a "project.options" file that only changed its date but the diff was empty (as the content was unchanged). There is a bug on git that makes git gui enter on an infinite loop: while it detect changes on file and diff is empty, a rescan is performed, then the same change is detected and enter on a rescan loop.
There is a patch to solve this, but it was easier just to add a silly comment on that only file (not in all your project.options) and then "git gui" was happy again and i could reset the changes on the branch.