在 Eclipse 中使用愚蠢的项目结构设置源类路径

发布于 2024-08-31 23:53:05 字数 522 浏览 2 评论 0原文

例如,当您有使用 ant 构建的大型项目时,您会做什么,其中源文件夹位于根项目文件夹的正下方,用于从源文件构建类路径?

将整个项目作为源文件夹是无意义的。
如果单独的文件夹是包层次结构的一部分,则无法将它们作为源文件夹,我唯一能想到的就是将源文件夹复制到一个单独的文件夹中,然后将其添加为源文件夹,这很奇怪,但我不知道还能怎么做。
仅仅因为 Eclipse 制作类路径的方式以及因为有人做了愚蠢的项目结构而必须复制源代码

这真的很痛苦......因为 ant 脚本是为这种结构编写的。
即使只是一个文件夹,这也是一个问题。必须将上层文件夹包含到源类路径中,这意味着它包含在所有垃圾中,并且还意味着包资源管理器中充满了包。

示例:
我们可以将 src 文件夹放入源类路径中,而不是 /project/src/java/utils ...
项目中还有 project/java/utils + 很多像 /project/docs 这样的废话。

What do you guys do, when you have huge project built with ant for instance, where the source folders are right bellow the root project folder, for building classpath from source files ?

Putting entire project as a source folder is nonsense.
Putting separate folders as source folders can't be done if they are part of the package hierarchy and the only thing I could think of, is to copy the source folders into a separate folder and add it then as source folder which is weird but I don't know how else to do it.
Having to duplicate sources just because of the eclipse way of making classpath and also because of somebody doing stupid project structure

It's really pain in the ass...because the ant scripts are written for this structure.
Even if it was just one folder, it's a problem anyway. There must be included the upper folder to the source classpath which means it is included with all the crap around and also it means that package explorer is flooded with the packages.

example:
Instead of /project/src/java/utils where we can put src folder into source classpath...
there is project/java/utils + lot of crap like /project/docs is in the project as well.

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

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

发布评论

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

评论(2

两个我 2024-09-07 23:53:05

诀窍是:

Eclipse 项目根目录由 .project.classpath 所在位置定义。

这里有两个选项:

  1. 那些 Eclipse 项目文件位于工作区中(而“project”,即内部带有“java/utils”的文件则不在工作区中)
    然后你可以创建一个链接文件夹在 Eclipse 项目中引用“project”,将该链接文件夹调用为“src”,并将其用作源文件夹。
    替代文本
    ant 脚本保留在原来的位置(在“project”目录中,以及所有其他子目录中)

  2. 这些 Eclipse 项目文件直接位于“project”中' 目录(以及 'java' 和 'docs':不要。
    删除该 Eclipse 项目(不是其内容,仅是其定义,这只会删除 .eclipse.classpath),并在其他位置重新创建。
    然后返回 1。

The trick is:

An Eclipse project root directory is defined by where the .project and .classpath are.

Two options here:

  1. Those Eclipse project files are located in the workspace (and the 'project', the one with 'java/utils' inside, is not)
    Then you can make a linked folder within the Eclipse project to reference 'project', calling that linked folder as 'src', using it as your source folder.
    alt text
    The ant script remains right where it originally is (in the 'project' directory, along with all the other sub-directories)

  2. Those Eclipse project files are located directly within the 'project' directory (along with 'java' and 'docs': don't.
    Delete that Eclipse project (not its content, only its definition, that will only remove the .eclipse and the .classpath), and recreate anywhere else.
    Then go back to 1.

如痴如狂 2024-09-07 23:53:05

对于 Eclipse 中的每个源文件夹,您可以选择要包含或排除的子文件夹作为源文件夹(您也可以使用模式)。如果我理解正确,在您的情况下,您可以将项目根文件夹添加为源文件夹,并仅包含那些包含源的文件夹。因此,在您的示例中,仅包含“java”。

For each source folder in eclipse you can choose which subfolders of it you want to include or exclude as a source folder (you can also use patterns). If I understand correctly, in your situation you can add the project root folder as a source folder and include only those folders that contain source. So in your example only "java" would be included.

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