mill-osgi - Build OSGi Bundles with mill

Quickstart

File: build.sc
// build.sc default imports
import mill._, mill.scalalib._
// This import the mill-osgi plugin
import $ivy.`de.tototec::de.tobiasroeser.mill.osgi:0.0.6`
import de.tobiasroeser.mill.osgi._

object project extends ScalaModule with OsgiBundleModule {

  def bundleSymbolicName = "com.example.project"

  def osgiHeaders = T{ super.osgiHeaders().copy(
    `Export-Package`   = Seq("com.example.api"),
    `Bundle-Activator` = Some("com.example.internal.Activator")
  )}

  // other settings ...

}

Use mill 0.3.6 or newer, to build the OSGi bundle.

$ mill project.osgiBundle
[27/38] project.compile
[info] Compiling 1 Scala source to /tmp/project/out/project/compile/dest/classes ...
[info] Done compiling.
[38/38] project.osgiBundle

Please note, that the default jar target is also overriden, so that it depends on osgiBundle and in fact it returns the exact same bundle.

$ mill show project.jar
[1/1] show
[39/39] project.jar
"ref:14551bd1:/tmp/project/out/project/osgiBundle/dest/out.jar"

Defaults

By default mill-osgi tries to provide some sensible default values based on the current build setup.

Export-Package and Private-Package

By default, all output packages of the compile task will be added to the Private-Package header. No packages will be exported via Export-Package.

Bundle-SymbolicName

If the module does not extends PublishModule, the bundle symbolic name will be initializes with JavaModule.artifactName.

If the module extends PublishModule, the Bundle-SymbolicName is computed using from PublishModule.pomSettings.organization and JavaModule.artifactName. If the organization or the last segment of the organization is a prefix of the artifactName, than that redundant part is omited.

License

Apache License, version 2

Version Compatibility Matrix

Mill is still in active development, and has no stable API yet. Hence, not all mill-osgi versions work with every mill version.

The following table shows a matrix of compatible mill and mill-osgi versions.

Table 1. Version Compatibility Matrix
mill-osgi mill

0.0.1

0.2.8

0.0.2

0.2.8

0.0.3

0.3.2

0.0.4

0.3.2

0.0.5

0.3.5

0.0.6

0.3.6

Changelog

mill-osgi 0.0.6 - 2019-02-15

  • Version bump to mill-0.3.6 and use of new mill-api

  • Improved integration test setup

  • Added runtime detection of possibly incompatible mill runtime version

mill-osgi 0.0.5 - 2018-12-14

  • Reworked integration test setup

  • Version bump to mill-0.3.5 and use of os-lib

mill-osgi 0.0.4 - 2018-11-20

  • Added explicit scala-library dependency to released pom.xml

mill-osgi 0.0.3 - 2018-11-02

  • Changed packaging / pom dependency information so that loading into mill excludes mill dependencies

mill-osgi 0.0.2 - 2018-10-18

  • Improved default bundle symbolic name algorithm

  • Added support for -includeresource

  • Improved source docs

  • Don’t add non-existing resources to avoid bnd warnings/errors

  • Add more default headers when project is a PublishModule

mill-osgi 0.0.1 - 2018-10-10

  • Initial early release to gain user feedback