Eclipse中的相​​对路径 [英] Relative Paths in Eclipse

查看:165
本文介绍了Eclipse中的相​​对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Eclipse工作区被检入Subversion仓库。但是,如果我更改了工作区目录的名称,则不会加载项目文件,我必须重新导入它们,并重新设置任何与工作空间相关的设置。 Eclipse是否可以使用相对路径?我不是这个项目中唯一的团队成员,不幸的是另一个人拒绝遵循一个共同的目录组织方案。



编辑 >这些都是目前的java项目



编辑工作空间的数据库文件夹中有几个文件,第一个我在项目中找到的

 < workspace root> \.metadata\plugins\org.eclipse .core.resources\.projects\ProjectName\.location 

这个文件是 .location表示有一个基于文件的URL。在Eclipse尝试使用相对路径后,我做了一些研究,得出结论,URL是不可能的相对路径。



编辑以下是.classpath和.project内容



.CLASSPATH

 <?xml version =1.0encoding =UTF-8?> 
< classpath>
< classpathentry kind =srcpath =src/>
< classpathentry kind =conpath =org.eclipse.jdt.launching.JRE_CONTAINER/>
< classpathentry kind =outputpath =bin/>
< / classpath>

.PROJECT

 <?xml version =1.0encoding =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 !

解决方案

工作区从来没有真正意图进入源代码管理。也许我误解了你的设置,但是如果你试图在源代码控制中提交你的工作空间的.metadata文件夹,那么你将会遇到麻烦!



源代码控制中的工作区,您只应该自己放置项目。然后通过Subversive或其他subversion插件,从SCM获取项目。这将使eclipse自动为您的项目自动创建所有资源和配置,并且如果您拥有所有依赖项,则应自行编译。



为什么感觉需要将源控件中的整个元数据文件夹从头开始?



如果您正在寻找一种管理构建的简单方法,那么我建议您查看Ant ,Maven或其他此类工具来帮助您。如果要保留设置大部分都具有导出功能,我建议您获得一个专门的项目来存储这些设置,并将其置于源代码控制下,因为它不是自动化的,而是一旦设置完成后就不应该全部更改经常。通常我甚至会将.settings文件夹和.classpath从我的项目中过滤出来,然后将它们推送到SCM,并且根据需要让eclipse和maven插件为我们重新生成。到目前为止,从来没有把任何东西从SCM中恢复出来。设置新的声音有点长,但是使用所有插件的Eclipse安装,然后导入配置和项目真的很快。


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.

解决方案

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中的相​​对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆