4

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?

Sebastien Diot
  • 7,183
  • 6
  • 43
  • 85
  • I had a similar question that I eventually got an answer to: http://stackoverflow.com/questions/5052706/scala-in-osgi-container/7585229#7585229 Not sure how useful it will be to you. – Andriy Drozdyuk Nov 07 '11 at 22:10

4 Answers4

3

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

Jean-Philippe Pellet
  • 59,296
  • 21
  • 173
  • 234
  • I have found it, but you can't give that as a simple dependency (AFAIK). You have to create a local bundle using the Jar, and that is what was bothering me. I was expecting I should just have to give Eclipse an Update Site URL, so that I could stay up-to-date automatically. – Sebastien Diot Aug 08 '11 at 10:45
3

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).

Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
  • Yes, I have eventually discovered that. I wanted to post an answer myself about it, but Stack-Overflow would not let me, for some reason. Anyway. the problem is that the created plugin can run either as "Application" or "Product". I was trying to run it as Product, which fails. Scraping my project and starting from scratch I seem to have chosen "Application" and then it worked. I have no clue what the difference is. – Sebastien Diot Aug 08 '11 at 10:41
  • See http://www.vogella.de/articles/EclipseRCP/article.html#product_product for definition of a "Product" in Eclipse RCP. – Alexey Romanov Aug 08 '11 at 10:45
2

The URLs provided in the other answers are outdated.

I recommend using the bundle available on the Scala IDE update site:

http://download.scala-ide.org/sdk/lithium/e44/scala211/stable/site

2

The OSGi versions of the Scala libraries are available from Scala-tools.org: http://scala-tools.org/repo-releases/com/weiglewilczek/scala-lang-osgi/scala-library/

michid
  • 10,536
  • 3
  • 32
  • 59