windows Eclipse,导入项目但不复制
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7931318/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse, import project but don't copy
提问by andrea_crotti
I use Linux as primary operating system and I also have to work on a Windows virtual machine with Eclipse 3.7.
我使用 Linux 作为主要操作系统,而且我还必须使用 Eclipse 3.7 在 Windows 虚拟机上工作。
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.
我们正在使用 subversion,但对于 Linux,我很高兴将 git-svn 与 Emacs+magit 一起使用,效果很好。所以我希望能够在两个操作系统上处理相同的代码,并且只在 Linux 上进行真正的版本控制管理。
So I had the following thought:
1. share the directory with virtualbox
2. create the projects pointing to the shared directory
所以我有以下想法:
1.与virtualbox
共享目录2.创建指向共享目录的项目
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 therewithout touching the files?
编辑:
我在上次编辑中的最后一次尝试不起作用,所以我有一个更简单的问题。给定一个 git/svn/任何存储库结帐,为什么我不能简单地告诉 Eclipse 在那里创建一个项目而不触及文件?
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?
Eclipse 很难在那个位置创建它的 .project 吗?
而且由于显然没有“支持”的方式来做到这一点,是否有任何解决方法?
回答by oren zvi
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"
根据我的经验,分以下几个阶段(使用 Indigo 版本): 1. 创建新的空项目 2. 点击 File->import->file system 3. 在导入窗口中导入文件系统,勾选你想要的文件到新的项目文件夹 4. 单击导入窗口中的高级并勾选“在工作区中创建链接”
The new project should contain links to the original directory.
新项目应包含指向原始目录的链接。
回答by Paul Webster
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 在其工作区中修改和编译源代码。工作区的第一级是项目目录,+ 一个仅在该工作区实例本地的 .metadata。传统上,工作区包含它所处理的项目。
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.
Eclipse 还支持 2 种链接模式。一方面,当您在工作区中创建项目时,您会为其指定一个到文件系统上其他位置的绝对路径。例如,如果您在 git repo 中有 eclipse 项目,这很方便。
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.
在另一种模式下,您在本地工作区中创建项目。然后将文件夹(源、资源等)链接到文件系统上的其他位置。这对于不想在其 SCM 中保存 Eclipse 特定文件(.project、.classpath 等)的项目非常有用。
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).
您必须在每个操作系统上创建不同的工作区(没有办法解决这个问题)。但是您可以在每个工作区中创建项目并链接到公共位置(我不推荐这样做,但它是可行的)。
回答by Sergio Hdez.
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.
1)克隆您的存储库,但不直接克隆到您的工作区,在我的情况下,我使用了工作区2而不是工作区。
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.
2)在eclipse上,将workspace2上的所有项目都导入,但是没有标记“copy files to workspace”,所以源码留在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.
3) 在 git 上,您将看到在 project.options 文件(仅更改文件日期)和 .path 文件(某些行更改了其顺序)中出现了更改。由于它们都是不相关的更改,因此重置本地分支并丢弃这些更改。
Thats all, git sees no more changes and eclipse open the files properly!
就是这样,git 看不到更多变化,eclipse 正确打开文件!
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.
我遇到了一个值得在这里评论的奇怪问题:导入后我转到“git gui”查看更改,第一个更改的文件是“project.options”文件,它只更改了日期但差异为空(作为内容不变)。git 上有一个错误,使 git gui 进入无限循环:当它检测到文件更改并且 diff 为空时,执行重新扫描,然后检测到相同的更改并进入重新扫描循环。
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.
有一个补丁可以解决这个问题,但只需在该文件上添加一个愚蠢的注释(而不是在您的所有 project.options 中),然后“git gui”又很高兴,我可以重置分支上的更改。