我可以将 Eclipse 项目配置为在修改 jar 后重建吗?

发布于 2024-12-04 13:37:38 字数 478 浏览 0 评论 0原文

似乎当我重建我的 Eclipse 项目之一所依赖的 jar 文件时,Eclipse 没有注意到该 jar 已被修改,并且不会重建该项目。随后我必须进行手动清理构建。

具体来说,我使用 这个答案并将其保存在我的工作区项目之外的目录中。

我使用 jar 作为依赖项而不是让主项目直接依赖第二个项目的原因是因为主项目是用 Java 编写的,而 jar 项目是用 Scala 编写的。我发现 Scala 构建速度非常慢,因此我决定关闭该项目,并在每次对 Scala 项目进行更改时从 Eclipse 中手动构建 jar。

缺少“外部 jar 修改”检测是 Eclipse 错误/限制还是有办法启用此行为?

It seems that when I rebuild a jar file that one of my Eclipse projects depends upon, Eclipse doesn't notice that the jar has been modified, and doesn't rebuild the project. I subsequently have to do a manual clean build.

Specifically, I'm building the jar from within Eclipse using the technique given in this answer and keeping it in a directory outside my workspace projects.

The reason I am using the jar as a dependency instead of having the main project depend on the second project directly is because the main project is in Java and the jar project is in Scala. I've found the Scala builds to be very slow, so I decided to keep the project closed and manually build the jar from within Eclipse whenever I make changes to the Scala project.

Is this lack of "external jar modification" detection an Eclipse bug/limitation or is there a way to enable this behavior?

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

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

发布评论

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

评论(4

没︽人懂的悲伤 2024-12-11 13:37:38

问题可能是该 jar 位于您的 Eclipse 工作区之外,因此 Eclipse 无法看到更改。您需要修改 jar 位置和/或项目的 Java 构建路径配置以将 jar 引入工作区。

更好的选择是将该 jar 的源代码作为另一个 Eclipse 项目,并将该其他项目作为依赖项,这样您就不必为每次更改都重新构建 jar。

The problem likely that jar is outside of your Eclipse Workspace, so Eclipse can't see the changes. You need to modify jar location and/or project's Java Build Path configuration to bring jar inside Workspace.

A better alternative is to have sources for that jar as another Eclipse project and have that other project as dependency, so you won't have to rebuild jar for every change.

烧了回忆取暖 2024-12-11 13:37:38

我认为这可能更像是一个工作流程的事情。让 Eclipse 始终扫描所有依赖项以进行更改可能是相当重量级的。

如果您没有使用 Eclipse 来构建项目的某些部分,那么当您执行任何操作来修改其依赖项时,您应该刷新项目/工作区以便 Eclipse 接收更改,这似乎是合理的。
我使用 maven,所以对我来说,当我构建时,maven 会构建我的代码,分析外部依赖项并重写我的 .project.classpath 文件。我刷新了我的工作区,一切都是最新的。

我唯一的其他建议是,如果您可以控制对该依赖项的更改,请将源作为项目添加到 eclipse 并将其添加为 eclipse 中的项目依赖项,而不是 jar 依赖项。

I think this is probably more of a worklflow thing. Having eclipse scanning all dependencies at all times for changes would probably be quite heavyweight.

If you are not using eclipse to build some part of your project, it would seem reasonable that when you execute whatever action to modify its dependencies, that you should refresh your project/workspace in order for eclipse to pick up the changes.
I use maven, so for me when I build, maven builds my code, analyses the external dependencies and rewrites my .project and .classpath files. I refresh my workspace and everything is up to date.

My only other suggestion is, if you are in control of the changes to that dependency, add the source as a project to eclipse and add it as a project dependency in eclipse, not a jar dependency.

删除会话 2024-12-11 13:37:38

除非我完全遗漏了某些内容,否则您只需右键单击项目中的 jar 文件,然后单击“刷新”即可。它至少可以在 Eclipse Juno 中运行。

Unless I'm missing something entirely, you can just right-click on the jar file in your project, and then click "Refresh". It works in Eclipse Juno at least.

生来就爱笑 2024-12-11 13:37:38

我建议使用构建工具(例如 Maven)来管理这样的依赖关系。
Eclipse 支持构建 Maven 项目。

I'd suggest using a build tool - like Maven - that will manage dependencies like this.
Eclipse has support for building Maven projects.

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