2

once again it has happened... I joined a new project, composed of several plain Eclipse Java Projects, with interdependencies, all managed through the Project build path. I find this all a bit of a chaos. And when it comes to run configurations - you just enter hell.

In the past I've sticked to create plug-in projects, instead of plain Java projects - even if I never intend to run these projects as osgi-bundles. I just find that dependencies are way easier to manage in plug-in projects. Are other people taking the same path? Anything against this approach?

4

6 回答 6

2

我同意在 Eclipse 中使用 OSGi 管理项目依赖项比添加项目或库引用的传统方式更容易。

但是,如果您在开发时推广 OSGi 方式的依赖管理,开发人员将需要学习 OSGi,并且在遇到类可见性问题时会产生成本。

您是使用Require-Bundle还是Import-Package管理依赖项?尽管Require-Bundle不是 OSGi 的推荐选择,但从开发时依赖管理的角度来看,它可能更适合。

除非您使用的是 Maven 插件之类的东西,否则 Eclipse 会在 Eclipse 内部和外部编译/运行完全不同的方法令人讨厌地分裂 - 维护 2 个并行编译/运行系统的痛苦。

于 2009-09-09T08:59:20.123 回答
2

如果您阅读org.aspectj 文档的重组,该项目正是这样做的:

  • 所有依赖项都将在 OSGi 包清单文件中表示,这些文件指定类路径(用于库 jar)和“必需”包。
    部署环境中预期或希望的库(例如XMLJRocket)必须包含在构建和测试目的中,但不包括在交付产品中。这些可能被指定为“可选”的 required-bundles 或 required-packages

  • 初始二进制程序集将通过通常的包程序集工作,包输出包括来自它需要的包片段的二进制文件(但不是来自可选包)

好处还包括 OSGi 的版本方面,它允许指定依赖项的最小和最大预期版本。

于 2009-09-07T18:56:18.980 回答
1

我认为你的方法,即使你不会在 OSGi 容器中运行,也使用 OSGi 进行依赖管理,非常合理,因为最终它将导致更多的模块化代码。模块化代码更容易重构,更容易在多个开发人员之间分发。您甚至不需要扩展任何 OSGi 类,因此您无需创建任何额外的依赖项。

另一方面,Ken Liu 提出的使用外部依赖管理的建议也有它的优势,因为像 Maven 之类的东西会为你处理很多依赖和管理。

将两者结合起来,您将获得两全其美。可以使用Bndm2eclipse等附加库使 OSGi 与 Maven 一起工作。

于 2009-09-07T19:13:24.357 回答
0

It sounds like an interesting approach, but personally I think it is best to manage build dependencies using an external build tool like Ant or Maven rather than tying your build to an IDE. If you use maven and the m2eclipse plugin, it will automatically set up Eclipse project dependencies when loading the Maven POM if those other projects are also in your workspace.

Unfortunately, if your team is currently using ad-hoc dependency management, it is kind of unlikely they will want to make the effort to jump to Maven. Then again, maybe they just need a leader to spearhead the effort.

于 2009-09-07T18:54:18.857 回答
0

我个人不会使用插件项目,我会使用 Ant、Maven 等构建工具。

如果没有集成构建系统,则意味着该公司对软件开发了解不多。

我不会承担引入构建系统的所有责任,可能会加班。如果他们不想迁移,我建议你尽快开始寻找另一份工作。

于 2009-09-07T19:13:10.193 回答
0

这里有两个不同的问题。

  1. 如何设置多个项目,以及
  2. 哪个构建系统允许我构建多个项目

两者不需要相关。因此,例如,您可能会选择 Maven 来构建项目,但使用插件项目来实现更轻松的编辑。大多数事情都击败了 Eclipse 构建系统。一旦它开始工作,它就会相当稳定 - 但让它从无到有工作涉及(a)运气和/或(b)黑魔法。

最终,问题归结为您觉得更容易管理的问题;两种类型的依赖,或者只是一种。如果你想要一个,那么你需要花时间在 m2eclipse(它从 maven POM 生成项目依赖项)或使用 pax-construct(它可以从 maven POM 生成清单)之类的东西上。要么,要么使用两个依赖管理系统。

于 2009-09-08T21:32:37.810 回答