Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala Library as an OSGi Bundle

Tags:

scala

osgi

I made a simple Eclipse RCP client, and now I want to turn it into a Scala application. Adding the Scala nature allows the IDE to compile the code, but it won't run because Scala is not available as an OSGi bundle. Searching the web only returned contradictory information, which seems to mean that there is no "standard" way to do it. I have found a recent post which says to use this link:

scala-eclipse-toolchain-osgi-2.9.0-1

But Eclipse says: "There are no available items there". I can go there with the browser, and see there is stuff. But I don't know the underlying mechanism of OSGi, so I can't tell what is wrong. I could create myself a bundle from the jars, but this is stupid. Scala must be already available somewhere as a pre-defined OSGi bundle!

[EDIT] I tried creating the bundle myself, as I had done with the Slick-Util, but it didn't work either. This does not make logical sense. I don't get how creating a bundle from a Jar can work for Jar A, but not for Jar B. I even copied the working self-made Slick-Util bundle, replaced the jar with scala-library.jar, and updated the bundle name and other setting everywhere, and it still will not work. My guess is that there is something wrong with the scala-library.jar itself, that prevents Eclipse from being able to use it. Maybe what is in it's Manifest?

like image 546
Sebastien Diot Avatar asked Dec 28 '22 16:12

Sebastien Diot


2 Answers

Adding the Scala nature allows the IDE to compile the code, but it won't run because Scala is not available as an OSGi bundle.

The Scala library provided with the Eclipse plug-in is an OSGi bundle. Open your MANIFEST.MF and check if org.scala-ide.scala.library is present in the Dependencies tab (if you added Scala nature to a plug-in project, it should have been added automatically, but not if you added plug-in nature to a Scala project).

But Eclipse says: "There are no available items there". I can go there with the browser, and see there is stuff. But I don't know the underlying mechanism of OSGi, so I can't tell what is wrong.

Eclipse is not looking for OSGi bundles, but for an update site (which contains features which contain other features and bundles).

like image 185
Alexey Romanov Avatar answered Jan 12 '23 22:01

Alexey Romanov


You can find the OSGi-fied Scala jars there: https://github.com/weiglewilczek/scala-lang-osgi.

like image 21
Jean-Philippe Pellet Avatar answered Jan 12 '23 21:01

Jean-Philippe Pellet