I'm using the sbtosgi plugin to generate an OSGi bundle from an sbt build using bnd. The sbtosgi bundle provides the osgi-bundle task for generating the bundle. Using the default configuration for sbtosgi, running osgi-bundle from the sbt prompt updates the JAR to include the proper headers, but running clean package results in a JAR without OSGi headers. In Maven speak, I'm trying to do the equivalent of using maven-bundle-plugin with packaging = bundle -- i.e., the main artifact of the project should be an OSGi bundle.
Based on reading the source of sbtosgi plugin, it appears to me that the osgi-bundle task overwrites the JAR created by packageBin. I tried overriding the definition of packageBin so that it used osgi-bundle task instead of the default task:
packageBin in Compile <<= OsgiKeys.bundle
This resulted in a cyclic reference though:
[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
I'm rather new to SBT and I'm not sure where to go from here. Any help would be appreciated.
Looks like my initial suggestion via Twitter which you used does not work. Sorry for that. But luckily I had Mark Harrah sitting next to me and here comes a working solution:
packagedArtifact in (Compile, packageBin) <<= (artifact in (Compile, packageBin), OsgiKeys.bundle).identityMap
artifact in (Compile, packageBin) ~= (_.copy(`type` = "bundle"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With