8

I am new to Scala. However, I a created a medium size program with Scala 2.9.0. Now I want to use an open source library which is only available for Scala 2.7.7.

Is it possible to use this 2.7.7 library in my Scala 2.9.0 program? How can I do it? I had already a look at sbt but did not really succeed. Has someone a hello world example for this?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Florian
  • 81
  • 1

3 Answers3

9

It should be possible in principle using a custom classloader for the 2.7.7 jar and custom wrappers. But practically, since the library is open source, it's very likely that it would be less work to recompile it with 2.9 and make those changes which are required. (There usually aren't many.)

Rex Kerr
  • 166,841
  • 26
  • 322
  • 407
  • 6
    There were some fairly big changes between 2.7 and 2.8, including source incompatibilities such as the new collections library. If you choose to update the open source library, this post might be a helpful guide: http://stackoverflow.com/questions/1243794/what-are-the-biggest-differences-between-scala-2-8-and-scala-2-7/2550803#2550803 Looking forward, the Scala team is putting more emphasis on backwards compatibility and migration tools. – Kipton Barros Aug 23 '11 at 18:46
  • @Kipton Barros - Structurally the changes were quite large, but most ports end up being fairly easy and mechanical _unless_ the code extended a bunch of collections classes. – Rex Kerr Aug 23 '11 at 19:20
3

Typesafe has an early preview of a migration manager (http://typesafe.com/technology/migration-manager) which promises to report on and resolve binary incompatibilities. Apparently the early preview only report on incompatibilities, but it might be worth a shot.

thoredge
  • 12,237
  • 1
  • 40
  • 55
1

The best approach would be to either use a maintained library or to update the code.

If you take the second option, compile the code with the flags -deprecation and -Xmigration.

This tells you what you need to change between versions.

soc
  • 27,983
  • 20
  • 111
  • 215