[sbtosgi] Using sbtosgi in Build.scala

149 views
Skip to first unread message

Ian de Beer

unread,
Jun 5, 2012, 8:30:11 AM6/5/12
to simple-b...@googlegroups.com

Hi

All the examples of using sbtosgi seems to be fairly trivial bundles that uses build.sbt. I am struggling to adapt the build.sbt to  Build.scala style. Does any one have an example or a reference on how to apply it in such a fashion?

Much obliged

Ian

philip142au

unread,
Jun 16, 2012, 1:04:23 AM6/16/12
to simple-b...@googlegroups.com
Hi Ian,

I also need to know how to use it.

I came across this example, but it doesn't compile.


Phil

de Beer Ian

unread,
Jun 16, 2012, 4:32:21 AM6/16/12
to simple-b...@googlegroups.com
Hi Phil
I have managed to get it working. Be sure to include the following in your Build.scala:

import com.typesafe.sbtosgi.OsgiPlugin._
...
  lazy val root = Project(id = "myProject", base = file("."), settings = Project.defaultSettings).settings(
    …
    OsgiKeys.bundleActivator := Some("com.example.osgi.actor.Activator"),
    OsgiKeys.exportPackage := Seq("com.example.osgi.actor")
 ).settings(osgiSettings: _*)

Hope it helps.
Ian


--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/uHwr2fuFwiwJ.
To post to this group, send email to simple-b...@googlegroups.com.
To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.

Heiko Seeberger

unread,
Jun 16, 2012, 4:32:34 AM6/16/12
to simple-b...@googlegroups.com
On Jun 5, 2012, at 2:30 PM, Ian de Beer wrote:

All the examples of using sbtosgi seems to be fairly trivial bundles that uses build.sbt. I am struggling to adapt the build.sbt to  Build.scala style.

There is nothing special about sbtosgi from a sbt point of view: sbtosgi just defines some new settings (and setting keys). Hence I suggest you try to understand how to transform any build.sbt to Build.scala. Have you read this: https://github.com/harrah/xsbt/wiki/Getting-Started-Full-Def

As a quick tip:

If your build.sbt has a line like
SomePluginsKeys.someKey := "foo"

Then your Build.scala should look somewhat like this:

object Build extends Build {

  lazy val root = Project(…)

  lazy val osgiProject = Project(
    "osgi-project",
    file("osgi-project"),
    settings = commonSettings ++ Seq(
      libraryDependencies ++= Seq(
        ...
      ),
      SomePluginsKeys.someKey := "foo"
    )

  def commonSettings = Seq(...)
  )
}

Does any one have an example or a reference on how to apply it in such a fashion?

For a real world example with a pretty sophisticated build definition including OSGi take a look at the Akka build:

Heiko

Brian Topping

unread,
Jul 6, 2013, 2:09:03 PM7/6/13
to simple-b...@googlegroups.com, heiko.s...@googlemail.com
For a real world example with a pretty sophisticated build definition including OSGi take a look at the Akka build:

Heiko

One of the things that would be really helpful is if sbt-osgi had debug output as to what's going on.  Myself and others are adding the plugin to the Spray build and I grabbed most of what I needed for an uberjar configuration from exactly that build, but I've suddenly found a different iteration of this work with a build that has no jar artifacts.  I spent some time learning how to get the debug output (using "last") and it's pretty cool how it works, but unfortunately for osgi-bundle, there is no usable output. I know from past experience that BND produces copious amounts of debugging, so I can only imagine that there's logging streams that are not getting redirected properly.  I got lucky to find that this kind of thing happens when ".*" is not added to exports, but I have no way at present to verify what (if anything, once axes are figured in) is being passed to the plugin.

Maybe in addition to redirecting BND output, some hints could be provided as to debugging this thing?  

Cheers, Brian
Reply all
Reply to author
Forward
0 new messages