pekko/project/OSGi.scala
Patrik Nordwall cbe5dd2cf5 +cdd #16799 Add Distributed Data module
Previously know as [patriknw/akka-data-replication](https://github.com/patriknw/akka-data-replication),
which was originally inspired by [jboner/akka-crdt](https://github.com/jboner/akka-crdt).

The functionality is very similar to akka-data-replication 0.11.

Here is a list of the most important changes:

* The package name changed to `akka.cluster.ddata`
* The extension was renamed to `DistributedData`
* The keys changed from strings to classes with unique identifiers and type information of the data values,
  e.g. `ORSetKey[Int]("set2")`
* The optional read consistency parameter was removed from the `Update` message. If you need to read from
  other replicas before performing the update you have to first send a `Get` message and then continue with
  the ``Update`` when the ``GetSuccess`` is received.
* `BigInt` is used in `GCounter` and `PNCounter` instead of `Long`
* Improvements of java api
* Better documentation
2015-06-18 15:58:22 +02:00

77 lines
3.6 KiB
Scala

package akka
import com.typesafe.sbt.osgi.SbtOsgi._
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(
packagedArtifact in (Compile, packageBin) <<= (artifact in (Compile, packageBin), OsgiKeys.bundle).identityMap
)
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
OsgiKeys.importPackage := (osgiOptionalImports map optionalResolution) ++ Seq("!sun.misc", scalaVersion(scalaImport).value, configImport(), "*"),
// dynamicImportPackage needed for loading classes defined in configuration
OsgiKeys.dynamicImportPackage := Seq("*")
)
val agent = exports(Seq("akka.agent.*"))
val camel = exports(Seq("akka.camel.*"))
val cluster = exports(Seq("akka.cluster.*"), imports = Seq(protobufImport()))
val clusterTools = exports(Seq("akka.cluster.singleton.*", "akka.cluster.client.*", "akka.cluster.pubsub.*"),
imports = Seq(protobufImport()))
val clusterSharding = exports(Seq("akka.cluster.sharding.*"), imports = Seq(protobufImport()))
val clusterMetrics = exports(Seq("akka.cluster.metrics.*"), imports = Seq(protobufImport(),kamonImport(),sigarImport()))
val distributedData = exports(Seq("akka.cluster.ddata.*"), imports = Seq(protobufImport()))
val contrib = exports(Seq("akka.contrib.*"))
val osgi = exports(Seq("akka.osgi.*"))
val remote = exports(Seq("akka.remote.*"), imports = Seq(protobufImport()))
val slf4j = exports(Seq("akka.event.slf4j.*"))
val persistence = exports(Seq("akka.persistence.*"), imports = Seq(protobufImport()))
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
// to be able to find refererence.conf
"akka.testkit",
"com.google.protobuf")
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(), scalaImport(scalaVersion), "*")
def akkaImport(packageName: String = "akka.*") = versionedImport(packageName, "2.4", "2.5")
def configImport(packageName: String = "com.typesafe.config.*") = versionedImport(packageName, "1.3.0", "1.4.0")
def protobufImport(packageName: String = "com.google.protobuf.*") = versionedImport(packageName, "2.5.0", "2.6.0")
def scalaImport(version: String) = {
val packageName = "scala.*"
val ScalaVersion = """(\d+)\.(\d+)\..*""".r
val ScalaVersion(epoch, major) = version
versionedImport(packageName, s"$epoch.$major", s"$epoch.${major.toInt+1}")
}
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"))
def optionalResolution(packageName: String) = "%s;resolution:=optional".format(packageName)
def versionedImport(packageName: String, lower: String, upper: String) = s"""$packageName;version="[$lower,$upper)""""
}