2016-02-23 12:58:39 +01:00
|
|
|
/**
|
2017-01-04 17:37:10 +01:00
|
|
|
* Copyright (C) 2016-2017 Lightbend Inc. <http://www.lightbend.com>
|
2016-02-23 12:58:39 +01:00
|
|
|
*/
|
2014-05-07 14:49:35 +02:00
|
|
|
package akka
|
|
|
|
|
|
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._
|
2016-10-28 16:41:26 +02:00
|
|
|
import com.typesafe.sbt.osgi.SbtOsgi.autoImport._
|
2014-05-07 14:49:35 +02:00
|
|
|
import sbt._
|
|
|
|
|
import sbt.Keys._
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
def osgiSettings = defaultOsgiSettings ++ Seq(
|
2016-08-04 13:14:30 +02:00
|
|
|
packagedArtifact in (Compile, packageBin) <<= (artifact in (Compile, packageBin), OsgiKeys.bundle).identityMap,
|
|
|
|
|
// 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
|
2016-12-13 21:37:41 +09:00
|
|
|
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()
|
2014-05-07 14:49:35 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
val actor = osgiSettings ++ Seq(
|
|
|
|
|
OsgiKeys.exportPackage := Seq("akka*"),
|
|
|
|
|
OsgiKeys.privatePackage := Seq("akka.osgi.impl"),
|
|
|
|
|
//akka-actor packages are not imported, as contained in the CP
|
2016-01-14 09:30:55 -07:00
|
|
|
OsgiKeys.importPackage := (osgiOptionalImports map optionalResolution) ++ Seq("!sun.misc", scalaJava8CompatImport(), scalaVersion(scalaImport).value, configImport(), "*"),
|
2014-05-07 14:49:35 +02:00
|
|
|
// dynamicImportPackage needed for loading classes defined in configuration
|
|
|
|
|
OsgiKeys.dynamicImportPackage := Seq("*")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
val agent = exports(Seq("akka.agent.*"))
|
|
|
|
|
|
|
|
|
|
val camel = exports(Seq("akka.camel.*"))
|
|
|
|
|
|
2015-02-18 00:15:50 +01:00
|
|
|
val cluster = exports(Seq("akka.cluster.*"))
|
2015-04-27 14:25:10 +02:00
|
|
|
|
2015-02-18 00:15:50 +01:00
|
|
|
val clusterTools = exports(Seq("akka.cluster.singleton.*", "akka.cluster.client.*", "akka.cluster.pubsub.*"))
|
2015-04-27 14:48:28 +02:00
|
|
|
|
2015-02-18 00:15:50 +01:00
|
|
|
val clusterSharding = exports(Seq("akka.cluster.sharding.*"))
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2015-02-18 00:15:50 +01:00
|
|
|
val clusterMetrics = exports(Seq("akka.cluster.metrics.*"), imports = Seq(kamonImport(), sigarImport()))
|
2015-05-17 12:28:47 +02:00
|
|
|
|
2015-02-18 00:15:50 +01:00
|
|
|
val distributedData = exports(Seq("akka.cluster.ddata.*"))
|
2014-12-12 11:49:32 -06:00
|
|
|
|
2015-06-06 09:16:49 -04:00
|
|
|
val contrib = exports(Seq("akka.contrib.*"))
|
|
|
|
|
|
2014-05-07 14:49:35 +02:00
|
|
|
val osgi = exports(Seq("akka.osgi.*"))
|
|
|
|
|
|
2015-02-18 00:15:50 +01:00
|
|
|
val protobuf = exports(Seq("akka.protobuf.*"))
|
|
|
|
|
|
|
|
|
|
val remote = exports(Seq("akka.remote.*"))
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2016-01-12 13:45:18 +01:00
|
|
|
val parsing = exports(Seq("akka.parboiled2.*", "akka.shapeless.*"),
|
|
|
|
|
imports = Seq(optionalResolution("scala.quasiquotes")))
|
|
|
|
|
|
2016-01-14 09:30:55 -07:00
|
|
|
val httpCore = exports(Seq("akka.http.*"), imports = Seq(scalaJava8CompatImport()))
|
2016-01-12 13:45:18 +01:00
|
|
|
|
2016-08-04 13:14:30 +02:00
|
|
|
val http = exports(Seq("akka.http.impl.server") ++
|
|
|
|
|
Seq(
|
|
|
|
|
"akka.http.$DSL$.server.*",
|
|
|
|
|
"akka.http.$DSL$.client.*",
|
|
|
|
|
"akka.http.$DSL$.coding.*",
|
|
|
|
|
"akka.http.$DSL$.common.*",
|
|
|
|
|
"akka.http.$DSL$.marshalling.*",
|
|
|
|
|
"akka.http.$DSL$.unmarshalling.*"
|
|
|
|
|
) flatMap { p =>
|
|
|
|
|
Seq(p.replace("$DSL$", "scaladsl"), p.replace("$DSL$", "javadsl"))
|
|
|
|
|
},
|
2016-01-13 01:28:59 +01:00
|
|
|
imports = Seq(
|
2016-01-14 09:30:55 -07:00
|
|
|
scalaJava8CompatImport(),
|
|
|
|
|
akkaImport("akka.stream.*"),
|
|
|
|
|
akkaImport("akka.parboiled2.*"))
|
2016-01-13 01:28:59 +01:00
|
|
|
)
|
2016-01-12 13:45:18 +01:00
|
|
|
|
2016-01-13 01:28:59 +01:00
|
|
|
val httpTestkit = exports(Seq("akka.http.scaladsl.testkit.*", "akka.http.javadsl.testkit.*"))
|
2016-01-12 13:45:18 +01:00
|
|
|
|
2016-01-13 01:28:59 +01:00
|
|
|
val httpSprayJson = exports(Seq("akka.http.scaladsl.marshallers.sprayjson"))
|
2016-01-12 13:45:18 +01:00
|
|
|
|
2016-01-13 01:28:59 +01:00
|
|
|
val httpXml = exports(Seq("akka.http.scaladsl.marshallers.xml"))
|
2016-01-12 13:45:18 +01:00
|
|
|
|
2016-01-13 01:28:59 +01:00
|
|
|
val httpJackson = exports(Seq("akka.http.javadsl.marshallers.jackson"))
|
2016-01-12 13:45:18 +01:00
|
|
|
|
2016-10-28 16:41:26 +02:00
|
|
|
val stream =
|
|
|
|
|
exports(
|
|
|
|
|
packages = Seq("akka.stream.*",
|
|
|
|
|
"com.typesafe.sslconfig.akka.*"),
|
2016-12-16 18:08:37 +01:00
|
|
|
imports = Seq(scalaJava8CompatImport(), scalaParsingCombinatorImport())) ++
|
2016-10-28 16:41:26 +02:00
|
|
|
Seq(OsgiKeys.requireBundle := Seq(s"""com.typesafe.sslconfig;bundle-version="${Dependencies.sslConfigVersion}""""))
|
2016-01-12 13:45:18 +01:00
|
|
|
|
2016-01-13 01:28:59 +01:00
|
|
|
val streamTestkit = exports(Seq("akka.stream.testkit.*"))
|
2016-01-12 13:45:18 +01:00
|
|
|
|
2014-05-07 14:49:35 +02:00
|
|
|
val slf4j = exports(Seq("akka.event.slf4j.*"))
|
|
|
|
|
|
2015-12-23 21:09:30 -07:00
|
|
|
val persistence = exports(Seq("akka.persistence.*"),
|
|
|
|
|
imports = Seq(optionalResolution("org.fusesource.leveldbjni.*"), optionalResolution("org.iq80.leveldb.*")))
|
2014-05-07 14:49:35 +02:00
|
|
|
|
2015-06-08 12:26:19 +02:00
|
|
|
val persistenceQuery = exports(Seq("akka.persistence.query.*"))
|
|
|
|
|
|
2014-05-07 14:49:35 +02:00
|
|
|
val testkit = exports(Seq("akka.testkit.*"))
|
|
|
|
|
|
|
|
|
|
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
|
2015-02-18 00:15:50 +01:00
|
|
|
"akka.testkit")
|
2014-05-07 14:49:35 +02:00
|
|
|
|
|
|
|
|
def exports(packages: Seq[String] = Seq(), imports: Seq[String] = Nil) = osgiSettings ++ Seq(
|
2014-11-30 15:53:41 +02:00
|
|
|
OsgiKeys.importPackage := imports ++ scalaVersion(defaultImports).value,
|
2014-05-07 14:49:35 +02:00
|
|
|
OsgiKeys.exportPackage := packages
|
|
|
|
|
)
|
2016-11-15 00:24:46 +01:00
|
|
|
def defaultImports(scalaVersion: String) = Seq("!sun.misc", akkaImport(), configImport(), "!scala.compat.java8.*",
|
|
|
|
|
"!scala.util.parsing.*", scalaImport(scalaVersion), "*")
|
2014-05-07 14:49:35 +02:00
|
|
|
def akkaImport(packageName: String = "akka.*") = versionedImport(packageName, "2.4", "2.5")
|
2015-06-10 11:22:14 +02:00
|
|
|
def configImport(packageName: String = "com.typesafe.config.*") = versionedImport(packageName, "1.3.0", "1.4.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
|
2015-02-09 12:18:48 -08:00
|
|
|
versionedImport(packageName, s"$epoch.$major", s"$epoch.${major.toInt+1}")
|
2014-11-30 15:53:41 +02:00
|
|
|
}
|
2016-01-14 09:30:55 -07:00
|
|
|
def scalaJava8CompatImport(packageName: String = "scala.compat.java8.*") = versionedImport(packageName, "0.7.0", "1.0.0")
|
2016-12-16 18:08:37 +01:00
|
|
|
def scalaParsingCombinatorImport(packageName: String = "scala.util.parsing.combinator.*") = versionedImport(packageName, "1.0.4", "1.1.0")
|
2014-12-12 11:49:32 -06: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)""""
|
|
|
|
|
}
|