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

mpi*_*ist 6 osgi scala sbt

我正在使用sbtosgi插件使用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
Run Code Online (Sandbox Code Playgroud)

这导致了循环引用:

[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
Run Code Online (Sandbox Code Playgroud)

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

Hei*_*ger 5

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

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

artifact in (Compile, packageBin) ~= (_.copy(`type` = "bundle"))
Run Code Online (Sandbox Code Playgroud)