如何管理OSGi构建依赖项?

时间:2022-06-24 07:15:06

We've embedded an OSGi runtime (Equinox) into out custom client-server application to facilitate plugin development and so far things are going great. We've been using Eclipse to build plugins due to the built-in manifest editor, dependency management, and export wizard. Using Eclipse to manager builds isn't very conducive to continuous integration via Hudson.

我们已经将OSGi运行时(Equinox)嵌入到自定义客户端 - 服务器应用程序中以促进插件开发,并且到目前为止事情进展顺利。由于内置的​​清单编辑器,依赖关系管理和导出向导,我们一直在使用Eclipse来构建插件。使用Eclipse管理构建不是非常有利于通过Hudson进行持续集成。

We have OSGi bundles which depend on other OSGi bundles. I'd really hate to hardcode build order in a custom ANT build. We've done this is the past and it's pretty horrible. Is there any build tool that can EASILY manage OSGi dependencies, if not automatically resolve them? Are there any DECENT examples of how to this?

我们有依赖于其他OSGi包的OSGi包。我真的很讨厌在自定义ANT构建中硬编码构建顺序。我们这样做是过去而且非常可怕。是否有任何构建工具可以轻松管理OSGi依赖项,如果不能自动解决它们?是否有任何DECENT示例如何做到这一点?

CLARIFICATION:

The generated build scripts are only usable via Eclipse. They require manually running pieces of Eclipse. We've also got some standard targets which the Eclipse build won't have, and I don't want to modify the generated file since I may regenerate (I know I can do includes, but I want to avoid the Eclipse gen file all together)

生成的构建脚本仅可通过Eclipse使用。它们需要手动运行Eclipse。我们还有一些Eclipse构建所不具备的标准目标,并且我不想修改生成的文件,因为我可以重新生成(我知道我可以做包含,但我想避免Eclipse gen文件全部一起)

Here is my project layout:

这是我的项目布局:

/
-PluginA
-PluginB
-PluginC
.
.
.

In using the Eclipse PDE, each plugin has a Manifest, but no build.xml as the PDE does that for me. Hard to automate a gui driven process w/ Hudson. I'd like to setup my own build.xml to build each, BUT there are dependencies and build order issues. These issues are driven by the Manifest files (which describe OSGi imports). For example, PluginC depends on PluginB which depends on PluginA. They must be built in the correct order. I realize that I can manually control the build order, I'm looking for a tool to help automate the build order dependency management.

在使用Eclipse PDE时,每个插件都有一个Manifest,但没有build.xml,因为PDE为我做了这个。 Hudson很难自动化gui驱动的流程。我想设置自己的build.xml来构建每个,但是存在依赖关系和构建顺序问题。这些问题由Manifest文件(描述OSGi导入)驱动。例如,PluginC依赖于PluginB,它依赖于PluginA。它们必须以正确的顺序构建。我意识到我可以手动控制构建顺序,我正在寻找一种工具来帮助自动化构建顺序依赖关系管理。

9 个解决方案

#1


7  

Maven2 all the way; has an Eclipse plugin called m2eclipse to help with managing it, solves exactly the dependency problem and then some. Has a free online book as documentation.

Maven2一路走来;有一个名为m2eclipse的Eclipse插件来帮助管理它,完全解决了依赖性问题,然后解决了一些问题。有一本免费的在线图书作为文档。

Specifically look at multi-module projects for bundling many components together and have Maven work out the build order and dependencies.

具体来看一下多模块项目,将许多组件捆绑在一起,让Maven解决构建顺序和依赖关系。

There is also a chapter on the Eclipse integration.

还有一章关于Eclipse集成。

And that is just Eclipse and Maven, next you get some cool goodies for OSGi:

那就是Eclipse和Maven,接下来你会为OSGi获得一些很酷的东西:

  • The Apache Felix BND Maven plugin will auto-generate your manifests or at the very least help you
  • Apache Felix BND Maven插件会自动生成您的清单,或者至少可以帮助您

  • The PAX OPS4J project and their Maven plugins can be a great help in bootstrapping projects, providing launchers, etc
  • PAX OPS4J项目及其Maven插件可以在启动项目,提供发射器等方面提供很大帮助

And just fundamentally, the Maven module model fits perfectly with OSGi's bundle model. We've been building and managing multiple products with hundreds of bundles using Maven for more than 3 years now and it's great.

从根本上说,Maven模块模型完全符合OSGi的捆绑模型。我们使用Maven已经使用Maven构建和管理多个产品已经超过3年了,而且非常棒。

#2


2  

We use Buckminster. It's a build and assembly framework, which takes care of the resolution of dependencies, the fetching from various repositories, building and packaging of the product.

我们使用Buckminster。它是一个构建和组装框架,负责解决依赖关系,从各种存储库中获取,构建和打包产品。

It's an Eclipse Tools project. It integrates well with PDE.

这是一个Eclipse Tools项目。它与PDE很好地集成。

This means that all the meta-data we use to build the RCP is useful to Buckminster to resolve and build. For example, feature.xml and the Require-Bundle header in the Manifest.MF, .product.

这意味着我们用于构建RCP的所有元数据对Buckminster解析和构建都很有用。例如,在Manifest.MF,.product中的feature.xml和Require-Bundle标头。

We haven't got any build scripts in each bundle now; we now have a single build per product. Buckminster takes care walking the dependency graph.

我们现在没有在每个包中都有任何构建脚本;我们现在每个产品都有一个版本。 Buckminster负责处理依赖图。

It took a little bit of effort to get our existing cruise-control/ant system working with it, though they (the Buckminster team) have started using Hudson to host the project itself. I believe that their build setup is also available for download.

尽管他们(Buckminster团队)已经开始使用Hudson来主持项目本身,但我们现有的巡航控制/蚂蚁系统需要花费一些力气才能完成。我相信他们的构建设置也可以下载。

We're really impressed with it, despite it's relative infancy.

我们对它印象深刻,尽管它相对不足。

We also looked into Pax-Construct but we didn't want to use Maven.

我们也调查了Pax-Construct,但我们不想使用Maven。

We're also currently looking at Spring DM testing framework to augment the unit testing effort.

我们目前还在研究Spring DM测试框架,以增强单元测试工作。

#3


2  

Seconding Maven2. Look into the Tycho plugins for building - they use Eclipse's JDT compiler so it implements all of the OSGi rules at compile-time, the same way Eclipse does at runtime.

借调Maven2。查看用于构建的Tycho插件 - 它们使用Eclipse的JDT编译器,因此它在编译时实现所有OSGi规则,就像Eclipse在运行时一样。

Alternatively, the Apache Felix BND plugins also seem popular. I prefer Tycho because it more closely seems to unify the Maven and Eclipse development environments.

或者,Apache Felix BND插件似乎也很受欢迎。我更喜欢Tycho,因为它更接近于统一Maven和Eclipse开发环境。

#4


1  

Closing out some old questions...

结束一些旧问题......

Our setup was not conducive to maven due to lack of network connectivity and timing. I know there are offline maven setups, but it was all too much given the time. Hopefully we'll get to use a proper setup when we've got time to reorganize the build process.

由于缺乏网络连接和时序,我们的设置不利于maven。我知道有离线maven设置,但考虑到时间太多了。希望在我们有时间重新组织构建过程时,我们将使用正确的设置。

The solution involved Ant, BND, and some custom ant tasks. The various bundle dependencies are manually managed. We were already using Ant; BND and custom tasks tied it all together. The custom tasks just made sure our bnd/eclipse projects were in sync.

该解决方案涉及Ant,BND和一些自定义ant任务。手动管理各种捆绑依赖项。我们已经在使用Ant; BND和自定义任务将它们捆绑在一起。自定义任务只是确保我们的bnd / eclipse项目是同步的。

#5


1  

PDE Headless build. It's well documented by Eclipse. If you're building Eclipse plugins, and you want to do it via command line, The Eclipse PDE headless build is THE way to go.

PDE无头构建。 Eclipse已有很好的文档记录。如果您正在构建Eclipse插件,并且您希望通过命令行来完成,那么Eclipse PDE无头构建是可行的方法。

#6


0  

Can you please elaborate where the problem occurs? You mention OSGi bundle dependencies. Is this during runtime? Or during compile-time? In the first case you should consider Declarative Services (see OSGi Spec).

你能详细说明问题出在哪里吗?您提到OSGi捆绑依赖项。这是在运行时吗?还是在编译期间?在第一种情况下,您应该考虑声明性服务(请参阅OSGi规范)。

#7


0  

We use Hudson combined with PluginBuilder to build our Eclipse-based OSGi bundles/plugins. This builds upon Eclipse's standard PDE process for building plugins. This means using Eclipse as the compiler.

我们使用Hudson结合PluginBuilder来构建基于Eclipse的OSGi包/插件。这构建于Eclipse的标准PDE流程之上,用于构建插件。这意味着使用Eclipse作为编译器。

#8


0  

Maven does not require internet connectivity! Use the -o switch, for Christ's sake.

Maven不需要互联网连接!为基督的缘故,使用-o开关。

#9


0  

I use maven 3.0.2

我使用maven 3.0.2

mvn generate:archetype

select 252 - osgi-archetype
mvn idea:idea

see http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

to add your dependencies into the bundle use this short example in the pom.xml

要将依赖项添加到bundle中,请使用pom.xml中的这个简短示例

<Export-Package>org.foo.myproject.api</Export-Package>

or

<Import-Package>org.foo.myproject.api</Import-Package>

#1


7  

Maven2 all the way; has an Eclipse plugin called m2eclipse to help with managing it, solves exactly the dependency problem and then some. Has a free online book as documentation.

Maven2一路走来;有一个名为m2eclipse的Eclipse插件来帮助管理它,完全解决了依赖性问题,然后解决了一些问题。有一本免费的在线图书作为文档。

Specifically look at multi-module projects for bundling many components together and have Maven work out the build order and dependencies.

具体来看一下多模块项目,将许多组件捆绑在一起,让Maven解决构建顺序和依赖关系。

There is also a chapter on the Eclipse integration.

还有一章关于Eclipse集成。

And that is just Eclipse and Maven, next you get some cool goodies for OSGi:

那就是Eclipse和Maven,接下来你会为OSGi获得一些很酷的东西:

  • The Apache Felix BND Maven plugin will auto-generate your manifests or at the very least help you
  • Apache Felix BND Maven插件会自动生成您的清单,或者至少可以帮助您

  • The PAX OPS4J project and their Maven plugins can be a great help in bootstrapping projects, providing launchers, etc
  • PAX OPS4J项目及其Maven插件可以在启动项目,提供发射器等方面提供很大帮助

And just fundamentally, the Maven module model fits perfectly with OSGi's bundle model. We've been building and managing multiple products with hundreds of bundles using Maven for more than 3 years now and it's great.

从根本上说,Maven模块模型完全符合OSGi的捆绑模型。我们使用Maven已经使用Maven构建和管理多个产品已经超过3年了,而且非常棒。

#2


2  

We use Buckminster. It's a build and assembly framework, which takes care of the resolution of dependencies, the fetching from various repositories, building and packaging of the product.

我们使用Buckminster。它是一个构建和组装框架,负责解决依赖关系,从各种存储库中获取,构建和打包产品。

It's an Eclipse Tools project. It integrates well with PDE.

这是一个Eclipse Tools项目。它与PDE很好地集成。

This means that all the meta-data we use to build the RCP is useful to Buckminster to resolve and build. For example, feature.xml and the Require-Bundle header in the Manifest.MF, .product.

这意味着我们用于构建RCP的所有元数据对Buckminster解析和构建都很有用。例如,在Manifest.MF,.product中的feature.xml和Require-Bundle标头。

We haven't got any build scripts in each bundle now; we now have a single build per product. Buckminster takes care walking the dependency graph.

我们现在没有在每个包中都有任何构建脚本;我们现在每个产品都有一个版本。 Buckminster负责处理依赖图。

It took a little bit of effort to get our existing cruise-control/ant system working with it, though they (the Buckminster team) have started using Hudson to host the project itself. I believe that their build setup is also available for download.

尽管他们(Buckminster团队)已经开始使用Hudson来主持项目本身,但我们现有的巡航控制/蚂蚁系统需要花费一些力气才能完成。我相信他们的构建设置也可以下载。

We're really impressed with it, despite it's relative infancy.

我们对它印象深刻,尽管它相对不足。

We also looked into Pax-Construct but we didn't want to use Maven.

我们也调查了Pax-Construct,但我们不想使用Maven。

We're also currently looking at Spring DM testing framework to augment the unit testing effort.

我们目前还在研究Spring DM测试框架,以增强单元测试工作。

#3


2  

Seconding Maven2. Look into the Tycho plugins for building - they use Eclipse's JDT compiler so it implements all of the OSGi rules at compile-time, the same way Eclipse does at runtime.

借调Maven2。查看用于构建的Tycho插件 - 它们使用Eclipse的JDT编译器,因此它在编译时实现所有OSGi规则,就像Eclipse在运行时一样。

Alternatively, the Apache Felix BND plugins also seem popular. I prefer Tycho because it more closely seems to unify the Maven and Eclipse development environments.

或者,Apache Felix BND插件似乎也很受欢迎。我更喜欢Tycho,因为它更接近于统一Maven和Eclipse开发环境。

#4


1  

Closing out some old questions...

结束一些旧问题......

Our setup was not conducive to maven due to lack of network connectivity and timing. I know there are offline maven setups, but it was all too much given the time. Hopefully we'll get to use a proper setup when we've got time to reorganize the build process.

由于缺乏网络连接和时序,我们的设置不利于maven。我知道有离线maven设置,但考虑到时间太多了。希望在我们有时间重新组织构建过程时,我们将使用正确的设置。

The solution involved Ant, BND, and some custom ant tasks. The various bundle dependencies are manually managed. We were already using Ant; BND and custom tasks tied it all together. The custom tasks just made sure our bnd/eclipse projects were in sync.

该解决方案涉及Ant,BND和一些自定义ant任务。手动管理各种捆绑依赖项。我们已经在使用Ant; BND和自定义任务将它们捆绑在一起。自定义任务只是确保我们的bnd / eclipse项目是同步的。

#5


1  

PDE Headless build. It's well documented by Eclipse. If you're building Eclipse plugins, and you want to do it via command line, The Eclipse PDE headless build is THE way to go.

PDE无头构建。 Eclipse已有很好的文档记录。如果您正在构建Eclipse插件,并且您希望通过命令行来完成,那么Eclipse PDE无头构建是可行的方法。

#6


0  

Can you please elaborate where the problem occurs? You mention OSGi bundle dependencies. Is this during runtime? Or during compile-time? In the first case you should consider Declarative Services (see OSGi Spec).

你能详细说明问题出在哪里吗?您提到OSGi捆绑依赖项。这是在运行时吗?还是在编译期间?在第一种情况下,您应该考虑声明性服务(请参阅OSGi规范)。

#7


0  

We use Hudson combined with PluginBuilder to build our Eclipse-based OSGi bundles/plugins. This builds upon Eclipse's standard PDE process for building plugins. This means using Eclipse as the compiler.

我们使用Hudson结合PluginBuilder来构建基于Eclipse的OSGi包/插件。这构建于Eclipse的标准PDE流程之上,用于构建插件。这意味着使用Eclipse作为编译器。

#8


0  

Maven does not require internet connectivity! Use the -o switch, for Christ's sake.

Maven不需要互联网连接!为基督的缘故,使用-o开关。

#9


0  

I use maven 3.0.2

我使用maven 3.0.2

mvn generate:archetype

select 252 - osgi-archetype
mvn idea:idea

see http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

to add your dependencies into the bundle use this short example in the pom.xml

要将依赖项添加到bundle中,请使用pom.xml中的这个简短示例

<Export-Package>org.foo.myproject.api</Export-Package>

or

<Import-Package>org.foo.myproject.api</Import-Package>