Eclipse 中的相对路径
我有一个已签入 Subversion 存储库的 Eclipse 工作区。但是,如果我更改工作区目录的名称,则项目文件不会加载,我必须重新导入它们,并再次设置任何与工作区相关的设置。 Eclipse 可以使用相对路径吗?我不是这个项目的唯一团队成员,不幸的是另一个人拒绝遵循通用的目录组织方案。
编辑 此时这些都是java项目
编辑工作区matadata文件夹中有几个文件,尽管这是我在中找到的第一个文件与项目的关系
<workspace root>\.metadata\plugins\org.eclipse.core.resources\.projects\ProjectName\.location
在这个文件“.location”中,有一个基于文件的 URL。在 Eclipse 崩溃后,当我尝试使用相对路径时,我做了一些研究,得出的结论是 URL 不可能使用相对路径。
编辑这里是.classpath和.project内容
.CLASSPATH
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
.PROJECT
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SimpleHelloWorld</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
出于配置和测试的目的,我一直在努力使这项工作正常进行只需使用我们简单的 Hello World!样本。
I have an Eclipse workspace that is checked into a Subversion repository. However, if I change the name of the workspace directory, the project files don't load and I have to re-import them, as well as set any workspace related settings again. Does Eclipse work with relative paths? I am not the only team member on this project, and unfortunately the other guy refuses to follow a common directory organization scheme.
EDIT These are all java projects at this point
EDIT There are several files in the workspace matadata folder, though here is the first one I found in relation to the project
<workspace root>\.metadata\plugins\org.eclipse.core.resources\.projects\ProjectName\.location
It is in this file ".location" that there is a file based URL. I did some research after Eclipse crashed when I tried to use a relative path and came to the conclusion that relative paths are not possible with URLs.
EDIT Here are the .classpath and .project contents
.CLASSPATH
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
.PROJECT
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SimpleHelloWorld</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
For purposes of configuration and testing, I have been trying to make this work only with our simple Hello World! sample.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
工作区从来就不是真正要进入源代码控制的。也许我误解了您的设置,但如果您尝试在源代码管理中提交工作区的 .metadata 文件夹,您将遇到一大堆麻烦!
您不应将工作区置于源代码管理中,而应仅放置项目本身。然后通过Subversive或者其他subversion插件,从SCM获取项目。这将使 Eclipse 自动为您的项目创建所有资源和配置,并且只要您拥有所有依赖项,它们就应该开箱即用地进行编译。
为什么您觉得需要将整个元数据文件夹放在源代码管理中?
如果您正在寻找一种简单的方法来管理构建,那么我建议您研究 Ant、Maven 或其他此类工具来帮助您。如果您想保留您的设置,其中大多数都具有导出功能,我建议您获得一个特殊的项目来存储这些设置并将其置于源代码控制之下,这并不理想,因为它不是自动化的,但一旦设置完毕,它们就不应该更改所有设置经常这样。通常我什至会从我的项目中过滤掉 .settings 文件夹和 .classpath,然后再将它们推送到 SCM,并让 eclipse 和 Maven 插件根据需要为我重新生成它们。到目前为止,我从 SCM 取回我的东西从来没有遇到过任何麻烦。设置一个新站点的时间有点长,但是使用包含所有插件的参考 Eclipse 安装,然后导入配置和项目非常快。
The workspace was never really meant to go in source control. Maybe I misunderstood your setup but if you are trying to commit the .metadata folder of your workspace in source control you are heading for a heap of trouble !
Instead of putting your workspace in source control you should only place the project themselves. Then through the Subversive or other subversion plugins, get the project from the SCM. This will have eclipse create automatically all the resources and configurations for your projects for you and they should compile right out of the box provided you have all the dependencies.
Why do you feel the need to have the whole metadata folder in source control to begin with ?
If you are looking for a simple way to manage the build then I suggest you look into Ant, Maven or other such tools to help you out. If you want to preserve your settings most of them have an export functionality, I suggest you get a special project to store these settings and place it under source control, not ideal because it is not automated but once they are setup they should not change all that often. Normally I even filter out the .settings folder and .classpath from my projects before pushing them to SCM and let eclipse and the maven plugin regenerate them for me as needed. Thus far I never really had any trouble getting my stuff back from SCM. Setting up a new sation is a bit longer but with a reference Eclipse installation with all the plugins then importing the configs and projects is really quick.
Eclipse 通常使用相对路径。在我的工作场所,我们使用带有 Subversive 插件的 Subversion 存储库。当我们进行全新导入时,我们不会遇到任何编译问题。
您可能需要编辑项目的 .project 和 .classpath 文件以查看是否存在对绝对位置的引用并将其更改为相对位置。
Eclipse does normally work with relative paths. In my workplace we use a Subversion Repository with the Subversive plugin. When we do a fresh import we don't have any problems for compilation.
You may want to edit the .project and .classpath files of your project to see if there is a reference to an absolute location and change it to be a relative one.
看起来 Eclipse 并不能用相对路径完成所有事情。
您可以做的一件便宜的事情是在不同机器上的相同路径中设置相同的预配置 Eclipse。
未来像 Eclipse Orion 这样的云 IDE 可能会解决此类问题...
It does not look like Eclipse can do everything with relative paths.
One cheap thing you can do is setup an identical preconfigured Eclipse in the same path on different machines.
In the future cloud IDEs like Eclipse Orion may solve such issues...