From 7558933b4bb42d7208f1548e3048d63e7564c598 Mon Sep 17 00:00:00 2001 From: Stefan Zeiger Date: Tue, 21 Mar 2017 18:03:12 +0100 Subject: [PATCH] Export the split packages and create correct import versions for OSGi --- build.sbt | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 0941f1d0..6487d9c2 100644 --- a/build.sbt +++ b/build.sbt @@ -19,9 +19,27 @@ val disablePublishing = Seq[Setting[_]]( disablePublishing // in root +/** Create an OSGi version range for standard Scala / Lightbend versioning + * schemes that describes binary compatible versions. */ +def osgiVersionRange(version: String): String = + if(version contains '-') "${@}" // M, RC or SNAPSHOT -> exact version + else "${range;[==,=+)}" // Any binary compatible version + +/** Create an OSGi Import-Package version specification. */ +def osgiImport(pattern: String, version: String): String = + pattern + ";version=\"" + osgiVersionRange(version) + "\"" + lazy val core = project.in(file("core")).settings(scalaModuleSettings).settings(scalaModuleOsgiSettings).settings( name := "scala-parallel-collections", - OsgiKeys.exportPackage := Seq(s"scala.collection.parallel.*;version=${version.value}"), + OsgiKeys.exportPackage := Seq( + s"scala.collection.parallel.*;version=${version.value}", + // The first entry on the classpath is the project's target classes dir but sbt-osgi also passes all + // dependencies to bnd. Any "merge" strategy for split packages would include the classes from scala-library. + s"scala.collection;version=${version.value};-split-package:=first", + s"scala.collection.generic;version=${version.value};-split-package:=first" + ), + // Use correct version for scala package imports + OsgiKeys.importPackage := Seq(osgiImport("scala*", scalaVersion.value), "*"), mimaPreviousVersion := None, headers := Map( "scala" ->