Skip to content

Commit 7558933

Browse files
committed
Export the split packages and create correct import versions for OSGi
1 parent 9239dcd commit 7558933

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

build.sbt

+19-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,27 @@ val disablePublishing = Seq[Setting[_]](
1919

2020
disablePublishing // in root
2121

22+
/** Create an OSGi version range for standard Scala / Lightbend versioning
23+
* schemes that describes binary compatible versions. */
24+
def osgiVersionRange(version: String): String =
25+
if(version contains '-') "${@}" // M, RC or SNAPSHOT -> exact version
26+
else "${range;[==,=+)}" // Any binary compatible version
27+
28+
/** Create an OSGi Import-Package version specification. */
29+
def osgiImport(pattern: String, version: String): String =
30+
pattern + ";version=\"" + osgiVersionRange(version) + "\""
31+
2232
lazy val core = project.in(file("core")).settings(scalaModuleSettings).settings(scalaModuleOsgiSettings).settings(
2333
name := "scala-parallel-collections",
24-
OsgiKeys.exportPackage := Seq(s"scala.collection.parallel.*;version=${version.value}"),
34+
OsgiKeys.exportPackage := Seq(
35+
s"scala.collection.parallel.*;version=${version.value}",
36+
// The first entry on the classpath is the project's target classes dir but sbt-osgi also passes all
37+
// dependencies to bnd. Any "merge" strategy for split packages would include the classes from scala-library.
38+
s"scala.collection;version=${version.value};-split-package:=first",
39+
s"scala.collection.generic;version=${version.value};-split-package:=first"
40+
),
41+
// Use correct version for scala package imports
42+
OsgiKeys.importPackage := Seq(osgiImport("scala*", scalaVersion.value), "*"),
2543
mimaPreviousVersion := None,
2644
headers := Map(
2745
"scala" ->

0 commit comments

Comments
 (0)