如何使用sbtosgi生成osgi bundle作为sbt发布任务的一部分

时间:2012-04-18 14:00:39

标签: scala osgi sbt

我正在使用sbtosgi plugin使用bnd从sbt构建生成OSGi包。 sbtosgi包提供用于生成包的 osgi-bundle 任务。使用sbtosgi的默认配置,从sbt提示符运行 osgi-bundle 会更新JAR以包含正确的标头,但运行 clean package 会导致JAR没有OSGi标头。在Maven中,我正在尝试使用包装= bundle来使用maven-bundle-plugin - 即项目的主要工件应该是OSGi包。

基于读取sbtosgi插件的来源,在我看来osgi-bundle任务会覆盖packageBin创建的JAR。我尝试重写packageBin的定义,以便它使用osgi-bundle任务而不是默认任务:

  packageBin in Compile <<= OsgiKeys.bundle

这导致了循环引用:

[error] Cyclic reference involving 
[error]    {file:project/*:osgi-bundle
[error]    {file:project/compile:full-classpath
[error]    {file:project/compile:exported-products
[error]    {file:project/compile:package-bin

我对SBT很新,我不知道从哪里开始。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:5)

看起来我通过Twitter的初步建议你使用不起作用。对不起。但幸运的是我让Mark Harrah坐在我旁边,这里有一个可行的解决方案:

packagedArtifact in (Compile, packageBin) <<= (artifact in (Compile, packageBin), OsgiKeys.bundle).identityMap

artifact in (Compile, packageBin) ~= (_.copy(`type` = "bundle"))
相关问题