No question: Scala is great! At least that’s what every Java developer would think. But just like Java Scala is lacking a higher-level module system. As there is currently no support for modularity built into the JVM, it is up to a framework to provide such. There is a well established and mature module framework around: OSGi. It lets us define modules called bundles which are just usual JARs with some additional metadata. But what are the benefits of going for OSGi bundles instead of plain JARs?
First, a bundle declares its public API and its dependencies. Hence we can really hide our implementations which gives us a great deal of flexibility.
Second, bundles, exported packages (public API) and imported packages (dependencies) use version numbers. This allows for installing the same bundle in different versions at the same time. No more JAR hell!
Third, OSGi is a dynamic module system: Bundles can be installed, updated and uninstalled anytime. This enables real hot deployment.
There are a lot of further benefits, e.g. a service-oriented architecture which enables loose coupling, different standard services for common tasks like logging, http, etc., but it should already be obvious, that OSGi makes a lot of sense.
As OSGi purely relies on Java, it is easy and straightforward to enable OSGi for Scala: Just provide the Scala libraries (scala-lang.jar, scala-swing.jar, etc.) as OSGi bundles with suitable bundle manifests. The “official” Scala libraries are not (yet) delivered as OSGi bundles. There is an Eclipse plug-in which is part of the Scala IDE for Eclipse which basically is an OSGi bundle, but it is an all-in-one bundle (assembles scala-*.jar) and - very important - contains a rather special bundle manifest that is not-so-good for general purpose.
Therefore I have created the scala-lang-osgi project which provides OSGi bundles for each Scala library. No changes are made to the libraries themselves but only the necessary manifest headers are added to the MANIFEST.MF file. All OSGi-fied Scala libraries are deployed to the scala-tools.org Maven repository with group id org.scala-lang-osgi using the same artifact id and version as the non-OSGi Scala libraries (e.g. scala-library, scala-swing, etc.). Of course there is also a snapshot repository.