2023-01-08 17:13:31 +08:00
|
|
|
/*
|
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
|
* license agreements; and to You under the Apache License, version 2.0:
|
|
|
|
|
*
|
|
|
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
2023-06-22 14:19:26 +01:00
|
|
|
* This file is part of the Apache Pekko project, which was derived from Akka.
|
2023-01-08 17:13:31 +08:00
|
|
|
*/
|
|
|
|
|
|
2019-01-02 18:55:26 +08:00
|
|
|
/*
|
2022-02-04 12:36:44 +01:00
|
|
|
* Copyright (C) 2016-2022 Lightbend Inc. <https://www.lightbend.com>
|
2016-02-23 12:58:39 +01:00
|
|
|
*/
|
2018-03-13 23:45:55 +09:00
|
|
|
|
2024-01-28 11:17:31 +11:00
|
|
|
import com.github.sbt.osgi.OsgiKeys
|
|
|
|
|
import com.github.sbt.osgi.SbtOsgi._
|
2014-05-07 14:49:35 +02:00
|
|
|
import sbt._
|
|
|
|
|
import sbt.Keys._
|
2024-01-09 20:54:13 +11:00
|
|
|
import sbtassembly.AssemblyKeys.assembly
|
2019-03-18 17:12:21 +01:00
|
|
|
import net.bzzt.reproduciblebuilds.ReproducibleBuildsPlugin
|
2014-05-07 14:49:35 +02:00
|
|
|
|
|
|
|
|
object OSGi {
|
|
|
|
|
|
|
|
|
|
// The included osgiSettings that creates bundles also publish the jar files
|
|
|
|
|
// in the .../bundles directory which makes testing locally published artifacts
|
|
|
|
|
// a pain. Create bundles but publish them to the normal .../jars directory.
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val osgiSettings =
|
2018-02-11 19:56:52 +01:00
|
|
|
defaultOsgiSettings ++ Seq(
|
|
|
|
|
Compile / packageBin := {
|
|
|
|
|
val bundle = OsgiKeys.bundle.value
|
|
|
|
|
// This normally happens automatically when loading the
|
|
|
|
|
// sbt-reproducible-builds plugin, but because we replace
|
|
|
|
|
// `packageBin` wholesale here we need to invoke the post-processing
|
|
|
|
|
// manually. See also
|
|
|
|
|
// https://github.com/raboof/sbt-reproducible-builds#sbt-osgi
|
|
|
|
|
ReproducibleBuildsPlugin.postProcessJar(bundle)
|
|
|
|
|
},
|
|
|
|
|
// This will fail the build instead of accidentally removing classes from the resulting artifact.
|
|
|
|
|
// Each package contained in a project MUST be known to be private or exported, if it's undecided we MUST resolve this
|
|
|
|
|
OsgiKeys.failOnUndecidedPackage := true,
|
|
|
|
|
// By default an entry is generated from module group-id, but our modules do not adhere to such package naming
|
|
|
|
|
OsgiKeys.privatePackage := Seq(),
|
|
|
|
|
// Explicitly specify the version of JavaSE required #23795 (rather depend on
|
|
|
|
|
// figuring that out from the JDK it was built with)
|
2023-10-12 11:29:12 -03:00
|
|
|
OsgiKeys.requireCapability := "osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(version>=1.8))\"",
|
|
|
|
|
// Recent versions of BND create corrupted jars so use JDK jar instead, see https://github.com/sbt/sbt-osgi/pull/81
|
|
|
|
|
OsgiKeys.packageWithJVMJar := true)
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val actor = osgiSettings ++ Seq(
|
2022-11-12 10:21:24 +01:00
|
|
|
OsgiKeys.exportPackage := Seq("org.apache.pekko*"),
|
|
|
|
|
OsgiKeys.privatePackage := Seq("org.apache.pekko.osgi.impl"),
|
2023-02-16 10:39:18 +01:00
|
|
|
// pekko-actor packages are not imported, as contained in the CP
|
2018-02-11 19:56:52 +01:00
|
|
|
OsgiKeys.importPackage := (osgiOptionalImports.map(optionalResolution)) ++ Seq(
|
|
|
|
|
"!sun.misc",
|
|
|
|
|
scalaJava8CompatImport(),
|
|
|
|
|
scalaVersion(scalaImport).value,
|
|
|
|
|
configImport(),
|
|
|
|
|
"*"),
|
|
|
|
|
// dynamicImportPackage needed for loading classes defined in configuration
|
|
|
|
|
OsgiKeys.dynamicImportPackage := Seq("*"))
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val actorTyped = exports(Seq("org.apache.pekko.actor.typed.*"))
|
2018-11-12 20:10:20 +01:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val cluster = exports(Seq("org.apache.pekko.cluster.*"))
|
2017-10-06 10:30:28 +02:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val clusterTools = exports(Seq("org.apache.pekko.cluster.singleton.*", "org.apache.pekko.cluster.client.*",
|
2022-11-12 10:21:24 +01:00
|
|
|
"org.apache.pekko.cluster.pubsub.*"))
|
2017-10-06 10:30:28 +02:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val clusterSharding = exports(Seq("org.apache.pekko.cluster.sharding.*"))
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val clusterMetrics =
|
|
|
|
|
exports(Seq("org.apache.pekko.cluster.metrics.*"), imports = Seq(kamonImport(), sigarImport()))
|
2017-10-06 10:30:28 +02:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val distributedData = exports(Seq("org.apache.pekko.cluster.ddata.*"))
|
2014-12-12 11:49:32 -06:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val osgi = exports(Seq("org.apache.pekko.osgi.*"))
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val protobufV3 = osgiSettings ++ Seq(
|
2020-07-28 16:13:18 +02:00
|
|
|
OsgiKeys.importPackage := Seq(
|
|
|
|
|
"!sun.misc",
|
|
|
|
|
scalaJava8CompatImport(),
|
|
|
|
|
scalaVersion(scalaImport).value,
|
|
|
|
|
configImport(),
|
|
|
|
|
"*"),
|
2022-11-12 10:21:24 +01:00
|
|
|
OsgiKeys.exportPackage := Seq("org.apache.pekko.protobufv3.internal.*"),
|
2024-01-09 20:54:13 +11:00
|
|
|
OsgiKeys.privatePackage := Seq("google.protobuf.*"),
|
|
|
|
|
// Since the jar's generated by sbt-assembly are not added in dependencyClasspath
|
|
|
|
|
// we need to manually add it to sbt-osgi so it can pick it up. Note that since this
|
|
|
|
|
// is a fatjar from sbt-assembly we don't have to worry about incorrect osgi
|
|
|
|
|
// Import-Package header since the protobuf-V3 sbt-project has no real dependencies
|
|
|
|
|
// (including typical ones such as scala runtime)
|
|
|
|
|
OsgiKeys.explodedJars := Seq(assembly.value))
|
2020-06-15 13:44:11 +02:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val jackson = exports(Seq("org.apache.pekko.serialization.jackson.*"))
|
2018-02-11 19:56:52 +01:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val remote = exports(Seq("org.apache.pekko.remote.*"))
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val stream =
|
2016-10-28 16:41:26 +02:00
|
|
|
exports(
|
2025-09-02 20:04:39 +01:00
|
|
|
packages = Seq("org.apache.pekko.stream.*"),
|
2018-11-12 20:10:20 +01:00
|
|
|
imports = Seq(
|
|
|
|
|
scalaJava8CompatImport(),
|
2025-09-02 20:04:39 +01:00
|
|
|
scalaParsingCombinatorImport()))
|
2016-01-12 13:45:18 +01:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val streamTestkit = exports(Seq("org.apache.pekko.stream.testkit.*"))
|
2016-01-12 13:45:18 +01:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val slf4j = exports(Seq("org.apache.pekko.event.slf4j.*"))
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val persistence = exports(
|
2022-11-12 10:21:24 +01:00
|
|
|
Seq("org.apache.pekko.persistence.*"),
|
2018-02-11 19:56:52 +01:00
|
|
|
imports = Seq(optionalResolution("org.fusesource.leveldbjni.*"), optionalResolution("org.iq80.leveldb.*")))
|
2018-11-12 20:10:20 +01:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val persistenceTyped = exports(Seq("org.apache.pekko.persistence.typed.*"))
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val persistenceQuery = exports(Seq("org.apache.pekko.persistence.query.*"))
|
2015-06-08 12:26:19 +02:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val testkit = exports(Seq("org.apache.pekko.testkit.*"))
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val discovery = exports(Seq("org.apache.pekko.discovery.*"))
|
2018-12-05 13:01:24 +00:00
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val coordination = exports(Seq("org.apache.pekko.coordination.*"))
|
2019-03-28 13:24:46 +01:00
|
|
|
|
2025-08-30 14:32:26 +02:00
|
|
|
lazy val pki = exports(Seq("org.apache.pekko.pki.*"))
|
|
|
|
|
|
2024-01-22 07:15:16 +01:00
|
|
|
lazy val osgiOptionalImports = Seq(
|
2014-05-07 14:49:35 +02:00
|
|
|
// needed because testkit is normally not used in the application bundle,
|
|
|
|
|
// but it should still be included as transitive dependency and used by BundleDelegatingClassLoader
|
2015-06-02 21:01:00 -07:00
|
|
|
// to be able to find reference.conf
|
2022-11-12 10:21:24 +01:00
|
|
|
"org.apache.pekko.testkit")
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2018-02-11 19:56:52 +01:00
|
|
|
def exports(packages: Seq[String] = Seq(), imports: Seq[String] = Nil) =
|
|
|
|
|
osgiSettings ++ Seq(
|
|
|
|
|
OsgiKeys.importPackage := imports ++ scalaVersion(defaultImports).value,
|
|
|
|
|
OsgiKeys.exportPackage := packages)
|
|
|
|
|
def defaultImports(scalaVersion: String) =
|
|
|
|
|
Seq(
|
|
|
|
|
"!sun.misc",
|
2023-02-17 10:49:40 +01:00
|
|
|
pekkoImport(),
|
2018-02-11 19:56:52 +01:00
|
|
|
configImport(),
|
|
|
|
|
"!scala.compat.java8.*",
|
|
|
|
|
"!scala.util.parsing.*",
|
|
|
|
|
scalaImport(scalaVersion),
|
|
|
|
|
"*")
|
2024-09-12 23:31:33 +02:00
|
|
|
def pekkoImport(packageName: String = "org.apache.pekko.*") = versionedImport(packageName, "1.1", "1.2")
|
2019-10-15 13:29:43 +02:00
|
|
|
def configImport(packageName: String = "com.typesafe.config.*") = versionedImport(packageName, "1.4.0", "1.5.0")
|
2014-11-30 15:53:41 +02:00
|
|
|
def scalaImport(version: String) = {
|
|
|
|
|
val packageName = "scala.*"
|
|
|
|
|
val ScalaVersion = """(\d+)\.(\d+)\..*""".r
|
|
|
|
|
val ScalaVersion(epoch, major) = version
|
2017-10-06 10:30:28 +02:00
|
|
|
versionedImport(packageName, s"$epoch.$major", s"$epoch.${major.toInt + 1}")
|
2014-11-30 15:53:41 +02:00
|
|
|
}
|
2018-02-11 19:56:52 +01:00
|
|
|
def scalaJava8CompatImport(packageName: String = "scala.compat.java8.*") =
|
2023-04-04 16:22:58 +02:00
|
|
|
versionedImport(packageName, "1.0.2", "1.0.2")
|
2018-02-11 19:56:52 +01:00
|
|
|
def scalaParsingCombinatorImport(packageName: String = "scala.util.parsing.combinator.*") =
|
|
|
|
|
versionedImport(packageName, "1.1.0", "1.2.0")
|
|
|
|
|
def kamonImport(packageName: String = "kamon.sigar.*") =
|
|
|
|
|
optionalResolution(versionedImport(packageName, "1.6.5", "1.6.6"))
|
|
|
|
|
def sigarImport(packageName: String = "org.hyperic.*") =
|
|
|
|
|
optionalResolution(versionedImport(packageName, "1.6.5", "1.6.6"))
|
2014-05-07 14:49:35 +02:00
|
|
|
def optionalResolution(packageName: String) = "%s;resolution:=optional".format(packageName)
|
|
|
|
|
def versionedImport(packageName: String, lower: String, upper: String) = s"""$packageName;version="[$lower,$upper)""""
|
|
|
|
|
}
|