在Eclipse中,如何进行与项目相关的启动配置?

发布于 2024-09-13 18:46:17 字数 647 浏览 3 评论 0原文

我通常有一个项目的多个副本,例如:主干的副本和最后一个发布分支的另一个副本。为了将我的项目文件与 Eclipse 完全分离,我们将它们从 Eclipse 工作区之外的目录中的 Subversion 中检出。

我想让项目轻松导入到 Eclipse 中,并遵循 多个 答案

问题是我的 .launch 文件的项目名称是硬编码的。导入新项目时,只要该项目与导出的项目名称完全相同,启动文件就会显示在“运行配置”菜单中一。这禁止我拥有同一项目的两个版本。

看起来唯一的方法是从 Ant 任务生成 .launch 和 .project 文件,但我没有看到有人使用此解决方案。也许我应该有多个工作区,并且项目始终具有相同的名称。

最好的方法是什么?

编辑:我将 VonC 标记为答案,但不要错过评论。

I usually have multiple copies of a project, for example: a copy of the trunk and another of the last release branch. To cleanly separate my project files from Eclipse, they are checked out from Subversion in a directory outside the Eclipse workspace.

I want to make the project easily importable to Eclipse and followed instructions from multiple answers.

The problem is that my .launch files have the project name hardcoded. When a new project is imported, the launch files will display in the Run Configurations menu just if the project has exactly the same name of the exported one. This forbids me to have two versions of the same project.

It looks like the only way to do it is to have the .launch and .project files generated from an Ant task, but I don't see anyone using this solution. Maybe I should have multiple workspaces and the project always with the same name.

What's the best way to do it?

Edit: I'm marking VonC as the answer, but don't miss the comments.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

找个人就嫁了吧 2024-09-20 18:46:17

请记住,.launch 配置文件不必位于您的工作区中。
正如我在 您引用的答案

这意味着您无法在 Eclipse 工作区中导入同一项目的两个版本。
您需要单独的工作区(本身没有版本控制),每个工作区都引用不同路径中的一个项目。
每个路径代表不同的工作树(就像 Subversion 的不同工作目录)。


OP 补充道:

项目必须具有相同的名称,但项目签出目录可以具有任何名称

要使启动文件正常工作,您必须使用变量 ${workspace_loc:ProjectName} 引用任何文件。
可以使用如下路径引用 Java 文件:“/ProjectName/src/package/MyFile.java
这样,就可以更轻松地使用任何工具与 subversion 存储库进行交互。

我想让 Eclipse 的使用者的生活变得更轻松,但我不想强迫任何人使用它。

Remember that the .launch configuration files don't have to be in your workspace.
They can be in your <project>/.settings as I mentioned in the answer you refer to.

That means you cannot import in your eclipse workspace two versions of the same project.
You need separate workspaces (not versioned themselves), each one referring to a project in a different path.
Each path represents different working trees (like different working directories for Subversion).


The OP adds:

The project must have the same name, but the project checkout dir can have any name.

To make the launch file work, you have to reference any file using the variable ${workspace_loc:ProjectName}.
Java files can be referenced using a path like: '/ProjectName/src/package/MyFile.java'
This way, it is easier to use any tool to interact with the subversion repository.

I want to make life easier for who uses Eclipse, but I don't want to force anyone to use it.

怪我入戏太深 2024-09-20 18:46:17

我的建议是将工作区绑定到签出位置,然后您可以在 Subversion 中使用相关项目的启动配置。

我的目录结构如下所示:

{checkout root}
   |
   +code
   |
   -workspace

在您的情况下,这意味着主干的工作区以及您签出的任何其他分支/标签。我还将所有项目都保留在工作空间之外。 Subversion 中的工作区目录是空的;我只是将项目引用从同级树递归添加到工作区。如果您导出 Eclipse 设置也会有所帮助,因为您可以将它们重新导入到每个新工作区中。

我从 IBM 和 Rational 的一对关于将 Eclipse 与 Rational ClearCase 结合使用的白皮书中得出了这种方法。除非您需要在同一工作区中打开同一项目的多个版本,否则这应该有效。

My recommendation is to tie the workspace to the checkout location, and then you can use the launch configurations for the relevant projects in Subversion.

My directory structure looks like this:

{checkout root}
   |
   +code
   |
   -workspace

In your case, that would mean a workspace for the trunk, and any other branch/tag you check out. I also keep all my projects outside the workspace. The workspace directory in Subversion is empty; I just recursively add the project reference(s) to the workspace from the sibling tree. It also helps if you export your Eclipse settings, as you can then re-import them into each new workspace.

I derived this approach from a pair of IBM and Rational white papers for using Eclipse with Rational ClearCase. This should work unless you need to have multiple versions of the same project open in the same workspace.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文