SBT OSGi Manager
OSGi development bridge based on Bnd and Tycho.
There is a sample project. Please, overview test
file which contains interactive example in Scripted format.
What is it? SBT Plugin for solid integration OSGi infrastructure with your favorite IDE.
It provides such abilities as:
- resolving OSGi dependencies and dependencies with source code at Eclipse P2 update site
- resolving OSGi dependencies via OSGi R5 repositories
- generating bundle manifest
Resolved bundles are added to project to 'library-dependencies' settings key. Resolved bundles and their source code (if any) may be fetched with sbt-dependency-manager or may be processed with your favorite tool that uses SBT dependency information (for example, SBT command deliver-local
).
Adding to your project
Via interactive build
Create a
- project/plugins/project/Build.scala - for older simple-build-tool
- project/project/Build.scala - for newer simple-build-tool
file that looks like the following:
import sbt._
object PluginDef extends Build {
override def projects = Seq(root)
lazy val root = Project("plugins", file(".")) dependsOn(osgi)
lazy val dm = uri("git://github.com/digimead/sbt-osgi-manager.git#TagOrCommit")
}
You may find more information about Build.scala in SBT documentation
As published jar artifact
Supported SBT versions: 0.11.3, 0.12.x. Add to your project/plugins.sbt
addSbtPlugin("org.digimead" % "sbt-osgi-manager" % "VERSION")
Maven repository:
resolvers += "digimead-maven" at "http://storage.googleapis.com/maven.repository.digimead.org/"
Ivy repository:
resolvers += Resolver.url("digimead-ivy", url("http://storage.googleapis.com/ivy.repository.digimead.org/"))(Resolver.defaultIvyPatterns)
As local build
Clone this repository to your development system then do sbt publish-local
.
Activate in your project
For build.sbt, simply add:
import sbt.osgi.manager._
OSGiManager
For Build.scala:
import sbt.dependency.manager._
... yourProjectSettings ++ OSGiManager
Imported package contains public declarations.
Usage
If you want to enable extra run-time debugging use OSGiManagerWithDebug(Equinox TCP port)
instead of OSGiManager
. Also put .options file to your project directory.
You may find the plugin usage examples at https://github.com/ezh/. Look at build.sbt
of Digi- libraries.
Please note, that OSGi infrastructure has no dependency organization
field as Ivy or Maven has. The bundle symbolic name and the bundle version identify a unique artifact.
Generate bundle manifest
To generate bundle manifest:
- Add necessary information your project. Look at Modify bundle properties
- Check bundle settings. Look at List actual properties per project
- Create your artifact as usual. The plugin will intercept
packageOptions in (Compile, packageBin)
and will inject OSGi headers to the generated manifest.
Modify bundle properties
You may alter bundle properties with complex block
inConfig(OSGiConf)({
import OSGiKey._
Seq[Project.Setting[_]](
osgiBndBundleActivator := "org.example.Activator",
osgiBndBundleSymbolicName := "org.example",
osgiBndBundleCopyright := "Copyright © 19xx-23xx N. All rights reserved.",
osgiBndExportPackage := List("org.example.*"),
osgiBndImportPackage := List("!org.aspectj.*", "*"),
osgiBndBundleLicense := Seq("http://www.gnu.org/licenses/agpl.html;description=GNU Affero General Public License",
"http://example.org/CommercialLicense.txt;description=Commercial License").mkString(","),
resolvers += typeP2("Eclipse P2 update site" at "http://eclipse.nn.nn"),
resolvers += typeOBR("Local OBR repository" at sys.env("OBR_REPOSITORY"))
)
})
You may alter bundle properties as single line from SBT settings.
OSGiKey.osgiBndBundleActivator in OSGiConf := "org.example.Activator"
List actual properties per project
You may inspect OSGi properties with SBT show
command or to use osgi-show
report.
Resolve OSGi dependencies
TODO doc
Resolve OSGi dependencies against P2 update site
TODO doc
inConfig(OSGiConf)({
import OSGiKey._
Seq[Project.Setting[_]](
resolvers += typeP2("Eclipse P2 update site" at "http://eclipse.ialto.com/eclipse/updates/4.2/R-4.2.1-201209141800/"),
libraryDependencies += typeP2((OSGi.ECLIPSE_PLUGIN % "org.eclipse.ui" % OSGi.ANY_VERSION).withSources),
libraryDependencies += typeP2((OSGi.ECLIPSE_PLUGIN % "org.eclipse.core.runtime" % OSGi.ANY_VERSION).withSources))
})
osgi-resolve
Resolver OSGi dependencies against OBR R5 repository
TODO doc
inConfig(OSGiConf)({
import OSGiKey._
Seq[Project.Setting[_]](
resolvers += typeOBR("Local OBR repository" at "file:/path/to/obr"),
libraryDependencies += typeOBR((OSGi.ANY_ORGANIZATION % "org.digimead.digi.lib" % OSGi.ANY_VERSION).withSources))
})
osgi-resolve