如何为添加到 Eclipse 工作区的项目使用相对路径? [英] How to use relative paths for projects added to an Eclipse workspace?

查看:29
本文介绍了如何为添加到 Eclipse 工作区的项目使用相对路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一些存储在 USB 密钥上的 Eclipse 项目.我已将它们添加到工作区,其根文件夹也位于 USB 密钥上,但项目并未直接位于此目录中.因此,它们的绝对路径被写入工作区的 .projects 文件夹中.

I am working on some Eclipse projects that are stored on a USB key. I have added them to a workspace whose root folder is also on the USB key, but the projects are not located directly into this directory. As a result their absolute paths are written in the .projects folder of the workspace.

当我在多台计算机上使用该密钥时会出现问题,因为分配给 USB 密钥的驱动器盘符并不总是相同(而且我不想在所有计算机上为其分配特定盘符).当驱动器号与我将项目添加到工作区时的 USB 密钥不同时,Eclipse 无法打开我的项目.

This raises problems when I use the key on several computers, because the drive letter assigned to the USB key is not always the same (and I do not want to assign a specific letter to it on all computers). Eclipse cannot open my projects when the drive letter differs from that of the USB key at the time I added the project to the workspace.

有没有办法解决这个问题?具体来说,有没有办法让 Eclipse 使用工作区文件夹中的相对路径将项目添加到工作区?

Is there a solution to this problem ? Specifically, is there a way to make Eclipse add projects to a workspace by using their relative path from the workspace folder ?

推荐答案

简而言之,如果不破解您的工作区元数据(在 [workspace.dir]/.metadata 下),您就无法做到这一点.Eclipse 工作区并非设计为可移植的,即使您没有实际移动工作区,实际上也是通过更改驱动器号来移动它.

The short answer is that you cannot do it without hacking your workspace metadata (under [workspace.dir]/.metadata). Eclipse workspaces aren't designed to be portable and even though you are not physically moving your workspace, you are in effect moving it by changing drive letters.

我建议尝试找到一种方法将您的项目放在 workspace.dir 下.不能保证您不会遇到问题,但可能会提高您的几率.根据您使用的 Eclipse 功能,您的工作区元数据中很可能会出现其他类型的绝对路径.

I'd recommend trying to find a way to have your projects under workspace.dir. Not guaranteed that you will not have problems that way, but may improve your odds. Depending on what features of Eclipse you use, you may very well end up with other types of absolute paths in your workspace metadata.

这篇关于如何为添加到 Eclipse 工作区的项目使用相对路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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