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
|
|
|
|
|
*
|
|
|
|
|
* This file is part of the Apache Pekko project, derived from Akka.
|
|
|
|
|
*/
|
|
|
|
|
|
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
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
package org.apache.pekko
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2016-08-04 13:14:30 +02:00
|
|
|
import com.typesafe.sbt.osgi.OsgiKeys
|
2014-05-07 14:49:35 +02:00
|
|
|
import com.typesafe.sbt.osgi.SbtOsgi._
|
|
|
|
|
import sbt._
|
|
|
|
|
import sbt.Keys._
|
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.
|
2018-02-11 19:56:52 +01:00
|
|
|
def osgiSettings =
|
|
|
|
|
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)
|
|
|
|
|
OsgiKeys.requireCapability := "osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(version>=1.8))\"")
|
2014-05-07 14:49:35 +02:00
|
|
|
|
|
|
|
|
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"),
|
2018-02-11 19:56:52 +01:00
|
|
|
// akka-actor packages are not imported, as contained in the CP
|
|
|
|
|
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
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val actorTyped = exports(Seq("org.apache.pekko.actor.typed.*"))
|
2018-11-12 20:10:20 +01:00
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val cluster = exports(Seq("org.apache.pekko.cluster.*"))
|
2017-10-06 10:30:28 +02:00
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val clusterTools = exports(Seq("org.apache.pekko.cluster.singleton.*", "org.apache.pekko.cluster.client.*",
|
|
|
|
|
"org.apache.pekko.cluster.pubsub.*"))
|
2017-10-06 10:30:28 +02:00
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val clusterSharding = exports(Seq("org.apache.pekko.cluster.sharding.*"))
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val clusterMetrics = exports(Seq("org.apache.pekko.cluster.metrics.*"), imports = Seq(kamonImport(), sigarImport()))
|
2017-10-06 10:30:28 +02:00
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val distributedData = exports(Seq("org.apache.pekko.cluster.ddata.*"))
|
2014-12-12 11:49:32 -06:00
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val osgi = exports(Seq("org.apache.pekko.osgi.*"))
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val protobuf = exports(Seq("org.apache.pekko.protobuf.*"))
|
2015-02-18 00:15:50 +01:00
|
|
|
|
2020-06-15 13:44:11 +02:00
|
|
|
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.*"),
|
2020-07-28 16:13:18 +02:00
|
|
|
OsgiKeys.privatePackage := Seq("google.protobuf.*"))
|
2020-06-15 13:44:11 +02:00
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val jackson = exports(Seq("org.apache.pekko.serialization.jackson.*"))
|
2018-02-11 19:56:52 +01:00
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val remote = exports(Seq("org.apache.pekko.remote.*"))
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2016-10-28 16:41:26 +02:00
|
|
|
val stream =
|
|
|
|
|
exports(
|
2022-11-12 10:21:24 +01:00
|
|
|
packages = Seq("org.apache.pekko.stream.*", "com.typesafe.sslconfig.pekko.*"),
|
2018-11-12 20:10:20 +01:00
|
|
|
imports = Seq(
|
|
|
|
|
scalaJava8CompatImport(),
|
|
|
|
|
scalaParsingCombinatorImport(),
|
|
|
|
|
sslConfigCoreImport("com.typesafe.sslconfig.ssl.*"),
|
|
|
|
|
sslConfigCoreImport("com.typesafe.sslconfig.util.*"),
|
2022-11-12 10:21:24 +01:00
|
|
|
"!com.typesafe.sslconfig.pekko.*"))
|
2016-01-12 13:45:18 +01:00
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val streamTestkit = exports(Seq("org.apache.pekko.stream.testkit.*"))
|
2016-01-12 13:45:18 +01:00
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val slf4j = exports(Seq("org.apache.pekko.event.slf4j.*"))
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2017-10-06 10:30:28 +02:00
|
|
|
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
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val persistenceTyped = exports(Seq("org.apache.pekko.persistence.typed.*"))
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val persistenceQuery = exports(Seq("org.apache.pekko.persistence.query.*"))
|
2015-06-08 12:26:19 +02:00
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val testkit = exports(Seq("org.apache.pekko.testkit.*"))
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val discovery = exports(Seq("org.apache.pekko.discovery.*"))
|
2018-12-05 13:01:24 +00:00
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
val coordination = exports(Seq("org.apache.pekko.coordination.*"))
|
2019-03-28 13:24:46 +01:00
|
|
|
|
2014-05-07 14:49:35 +02:00
|
|
|
val osgiOptionalImports = Seq(
|
|
|
|
|
// 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",
|
|
|
|
|
akkaImport(),
|
|
|
|
|
configImport(),
|
|
|
|
|
"!scala.compat.java8.*",
|
|
|
|
|
"!scala.util.parsing.*",
|
|
|
|
|
scalaImport(scalaVersion),
|
|
|
|
|
"*")
|
2022-11-12 10:21:24 +01:00
|
|
|
def akkaImport(packageName: String = "org.apache.pekko.*") = versionedImport(packageName, "2.6", "2.7")
|
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.*") =
|
2022-01-03 08:52:17 +01:00
|
|
|
versionedImport(packageName, "0.8.0", "2.0.0")
|
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 sslConfigCoreImport(packageName: String = "com.typesafe.sslconfig") =
|
2019-10-15 13:29:43 +02:00
|
|
|
versionedImport(packageName, "0.4.0", "1.0.0")
|
2018-02-11 19:56:52 +01:00
|
|
|
def sslConfigCoreSslImport(packageName: String = "com.typesafe.sslconfig.ssl.*") =
|
2019-10-15 13:29:43 +02:00
|
|
|
versionedImport(packageName, "0.4.0", "1.0.0")
|
2018-02-11 19:56:52 +01:00
|
|
|
def sslConfigCoreUtilImport(packageName: String = "com.typesafe.sslconfig.util.*") =
|
2019-10-15 13:29:43 +02:00
|
|
|
versionedImport(packageName, "0.4.0", "1.0.0")
|
2018-02-11 19:56:52 +01:00
|
|
|
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)""""
|
|
|
|
|
}
|