pekko/project/AkkaBuild.scala

508 lines
19 KiB
Scala
Raw Normal View History

/**
2012-01-19 18:21:06 +01:00
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
*/
2011-09-23 10:21:03 +02:00
package akka
2011-07-04 19:16:43 +12:00
import sbt._
2011-12-08 17:05:01 +13:00
import sbt.Keys._
2011-09-23 10:21:03 +02:00
import com.typesafe.sbtmultijvm.MultiJvmPlugin
2011-12-08 17:05:01 +13:00
import com.typesafe.sbtmultijvm.MultiJvmPlugin.{ MultiJvm, extraOptions, jvmOptions, scalatestOptions }
2011-09-23 10:21:03 +02:00
import com.typesafe.sbtscalariform.ScalariformPlugin
2011-12-08 17:05:01 +13:00
import com.typesafe.sbtscalariform.ScalariformPlugin.ScalariformKeys
import com.typesafe.sbtosgi.OsgiPlugin.osgiSettings
import com.typesafe.sbtosgi.OsgiKeys
2011-08-04 16:49:05 +12:00
import java.lang.Boolean.getBoolean
import Sphinx.{ sphinxDocs, sphinxHtml, sphinxLatex, sphinxPdf, sphinxPygments, sphinxTags }
2011-07-04 19:16:43 +12:00
object AkkaBuild extends Build {
System.setProperty("akka.mode", "test") // Is there better place for this?
2011-07-08 18:01:19 +12:00
lazy val buildSettings = Seq(
organization := "com.typesafe.akka",
2012-03-05 10:50:54 +13:00
version := "2.1-SNAPSHOT",
2012-04-13 18:31:52 +02:00
scalaVersion := "2.9.2"
2011-07-08 18:01:19 +12:00
)
2011-07-04 19:16:43 +12:00
lazy val akka = Project(
id = "akka",
base = file("."),
2012-05-09 17:50:31 +12:00
settings = parentSettings ++ Release.settings ++ Unidoc.settings ++ Sphinx.settings ++ Publish.versionSettings ++ Dist.settings ++ Seq(
testMailbox in GlobalScope := System.getProperty("akka.testMailbox", "false").toBoolean,
parallelExecution in GlobalScope := System.getProperty("akka.parallelExecution", "false").toBoolean,
2011-12-09 21:55:49 +13:00
Publish.defaultPublishTo in ThisBuild <<= crossTarget / "repository",
2011-07-08 12:53:36 +12:00
Unidoc.unidocExclude := Seq(samples.id, tutorials.id),
Dist.distExclude := Seq(actorTests.id, akkaSbtPlugin.id, docs.id),
// online version of docs
sphinxDocs <<= baseDirectory / "akka-docs",
sphinxTags in sphinxHtml += "online",
sphinxPygments <<= sphinxPygments in LocalProject(docs.id),
sphinxLatex <<= sphinxLatex in LocalProject(docs.id),
sphinxPdf <<= sphinxPdf in LocalProject(docs.id)
2011-07-08 10:20:10 +12:00
),
aggregate = Seq(actor, testkit, actorTests, remote, remoteTests, camel, cluster, slf4j, agent, transactor, mailboxes, zeroMQ, kernel, akkaSbtPlugin, samples, tutorials, docs)
2011-07-04 19:16:43 +12:00
)
lazy val actor = Project(
id = "akka-actor",
base = file("akka-actor"),
settings = defaultSettings ++ OSGi.actor ++ Seq(
autoCompilerPlugins := true,
libraryDependencies <+= scalaVersion { v => compilerPlugin("org.scala-lang.plugins" % "continuations" % v) },
scalacOptions += "-P:continuations:enable",
// to fix scaladoc generation
fullClasspath in doc in Compile <<= fullClasspath in Compile
2011-07-04 19:16:43 +12:00
)
)
lazy val testkit = Project(
id = "akka-testkit",
base = file("akka-testkit"),
dependencies = Seq(actor),
settings = defaultSettings ++ Seq(
libraryDependencies ++= Dependencies.testkit
)
)
lazy val actorTests = Project(
id = "akka-actor-tests",
base = file("akka-actor-tests"),
dependencies = Seq(testkit % "compile;test->test"),
2011-07-04 19:16:43 +12:00
settings = defaultSettings ++ Seq(
autoCompilerPlugins := true,
libraryDependencies <+= scalaVersion { v => compilerPlugin("org.scala-lang.plugins" % "continuations" % v) },
scalacOptions += "-P:continuations:enable",
2011-07-04 19:16:43 +12:00
libraryDependencies ++= Dependencies.actorTests
)
)
lazy val remote = Project(
id = "akka-remote",
base = file("akka-remote"),
dependencies = Seq(actor, actorTests % "test->test", testkit % "test->test"),
settings = defaultSettings ++ multiJvmSettings ++ OSGi.remote ++ Seq(
libraryDependencies ++= Dependencies.remote,
// disable parallel tests
parallelExecution in Test := false,
extraOptions in MultiJvm <<= (sourceDirectory in MultiJvm) { src =>
(name: String) => (src ** (name + ".conf")).get.headOption.map("-Dakka.config=" + _.absolutePath).toSeq
},
scalatestOptions in MultiJvm := defaultMultiJvmScalatestOptions,
2012-05-24 10:00:35 +02:00
jvmOptions in MultiJvm := defaultMultiJvmOptions,
test in Test <<= ((test in Test), (test in MultiJvm)) map { case x => x }
)
) configs (MultiJvm)
lazy val remoteTests = Project(
id = "akka-remote-tests",
base = file("akka-remote-tests"),
dependencies = Seq(remote % "compile;test->test;multi-jvm->multi-jvm", actorTests % "test->test", testkit % "test->test"),
settings = defaultSettings ++ multiJvmSettings ++ Seq(
// disable parallel tests
parallelExecution in Test := false,
extraOptions in MultiJvm <<= (sourceDirectory in MultiJvm) { src =>
(name: String) => (src ** (name + ".conf")).get.headOption.map("-Dakka.config=" + _.absolutePath).toSeq
},
scalatestOptions in MultiJvm := defaultMultiJvmScalatestOptions,
2012-05-24 10:00:35 +02:00
jvmOptions in MultiJvm := defaultMultiJvmOptions,
test in Test <<= ((test in Test), (test in MultiJvm)) map { case x => x }
)
) configs (MultiJvm)
lazy val cluster = Project(
id = "akka-cluster",
base = file("akka-cluster"),
dependencies = Seq(remote, remoteTests % "compile;test->test;multi-jvm->multi-jvm", testkit % "test->test"),
settings = defaultSettings ++ multiJvmSettings ++ OSGi.cluster ++ Seq(
libraryDependencies ++= Dependencies.cluster,
// disable parallel tests
parallelExecution in Test := false,
extraOptions in MultiJvm <<= (sourceDirectory in MultiJvm) { src =>
(name: String) => (src ** (name + ".conf")).get.headOption.map("-Dakka.config=" + _.absolutePath).toSeq
},
scalatestOptions in MultiJvm := defaultMultiJvmScalatestOptions,
2012-05-24 10:00:35 +02:00
jvmOptions in MultiJvm := defaultMultiJvmOptions,
test in Test <<= ((test in Test), (test in MultiJvm)) map { case x => x }
)
) configs (MultiJvm)
2011-07-04 19:16:43 +12:00
lazy val slf4j = Project(
id = "akka-slf4j",
base = file("akka-slf4j"),
2011-10-12 11:34:35 +02:00
dependencies = Seq(actor, testkit % "test->test"),
settings = defaultSettings ++ OSGi.slf4j ++ Seq(
2011-07-04 19:16:43 +12:00
libraryDependencies ++= Dependencies.slf4j
)
)
2011-12-19 15:46:06 +13:00
lazy val agent = Project(
id = "akka-agent",
base = file("akka-agent"),
dependencies = Seq(actor, testkit % "test->test"),
settings = defaultSettings ++ OSGi.agent ++ Seq(
2011-12-19 15:46:06 +13:00
libraryDependencies ++= Dependencies.agent
)
)
lazy val transactor = Project(
id = "akka-transactor",
base = file("akka-transactor"),
dependencies = Seq(actor, testkit % "test->test"),
settings = defaultSettings ++ OSGi.transactor ++ Seq(
libraryDependencies ++= Dependencies.transactor
)
)
val testMailbox = SettingKey[Boolean]("test-mailbox")
lazy val mailboxes = Project(
id = "akka-durable-mailboxes",
base = file("akka-durable-mailboxes"),
settings = parentSettings,
aggregate = Seq(mailboxesCommon, fileMailbox)
)
2011-07-04 19:16:43 +12:00
lazy val mailboxesCommon = Project(
id = "akka-mailboxes-common",
base = file("akka-durable-mailboxes/akka-mailboxes-common"),
dependencies = Seq(remote, testkit % "compile;test->test"),
settings = defaultSettings ++ OSGi.mailboxesCommon ++ Seq(
libraryDependencies ++= Dependencies.mailboxes,
// DurableMailboxSpec published in akka-mailboxes-common-test
publishArtifact in Test := true
)
)
2011-07-04 19:16:43 +12:00
lazy val fileMailbox = Project(
id = "akka-file-mailbox",
base = file("akka-durable-mailboxes/akka-file-mailbox"),
dependencies = Seq(mailboxesCommon % "compile;test->test", testkit % "test"),
settings = defaultSettings ++ OSGi.fileMailbox ++ Seq(
libraryDependencies ++= Dependencies.fileMailbox
)
)
2011-07-04 19:16:43 +12:00
lazy val zeroMQ = Project(
id = "akka-zeromq",
base = file("akka-zeromq"),
dependencies = Seq(actor, testkit % "test;test->test"),
settings = defaultSettings ++ OSGi.zeroMQ ++ Seq(
libraryDependencies ++= Dependencies.zeroMQ
)
)
lazy val kernel = Project(
id = "akka-kernel",
base = file("akka-kernel"),
2011-12-14 17:15:06 +13:00
dependencies = Seq(actor, testkit % "test->test"),
settings = defaultSettings ++ Seq(
libraryDependencies ++= Dependencies.kernel
)
)
lazy val camel = Project(
id = "akka-camel",
base = file("akka-camel"),
dependencies = Seq(actor, slf4j, testkit % "test->test"),
settings = defaultSettings ++ OSGi.camel ++ Seq(
libraryDependencies ++= Dependencies.camel
)
)
2011-07-04 19:16:43 +12:00
lazy val akkaSbtPlugin = Project(
id = "akka-sbt-plugin",
base = file("akka-sbt-plugin"),
settings = defaultSettings ++ Seq(
sbtPlugin := true,
scalaVersion := "2.9.1"
)
)
2011-07-04 19:16:43 +12:00
lazy val samples = Project(
id = "akka-samples",
base = file("akka-samples"),
2011-07-08 18:01:19 +12:00
settings = parentSettings,
aggregate = Seq(fsmSample, helloSample, helloKernelSample, remoteSample)
2011-07-04 19:16:43 +12:00
)
lazy val fsmSample = Project(
id = "akka-sample-fsm",
base = file("akka-samples/akka-sample-fsm"),
dependencies = Seq(actor),
settings = defaultSettings
)
2011-12-08 17:05:01 +13:00
lazy val helloSample = Project(
id = "akka-sample-hello",
base = file("akka-samples/akka-sample-hello"),
dependencies = Seq(actor),
settings = defaultSettings
)
2011-12-08 17:05:01 +13:00
lazy val helloKernelSample = Project(
id = "akka-sample-hello-kernel",
base = file("akka-samples/akka-sample-hello-kernel"),
dependencies = Seq(kernel),
settings = defaultSettings
)
lazy val remoteSample = Project(
id = "akka-sample-remote",
base = file("akka-samples/akka-sample-remote"),
dependencies = Seq(actor, remote, kernel),
settings = defaultSettings
)
2011-07-04 19:16:43 +12:00
lazy val tutorials = Project(
id = "akka-tutorials",
base = file("akka-tutorials"),
2011-07-08 18:01:19 +12:00
settings = parentSettings,
aggregate = Seq(firstTutorial)
2011-07-04 19:16:43 +12:00
)
lazy val firstTutorial = Project(
id = "akka-tutorial-first",
base = file("akka-tutorials/akka-tutorial-first"),
dependencies = Seq(actor, testkit),
settings = defaultSettings ++ Seq(
libraryDependencies ++= Dependencies.tutorials
)
2011-07-04 19:16:43 +12:00
)
lazy val docs = Project(
id = "akka-docs",
base = file("akka-docs"),
dependencies = Seq(actor, testkit % "test->test", mailboxesCommon % "compile;test->test",
remote, cluster, slf4j, agent, transactor, fileMailbox, zeroMQ, camel),
settings = defaultSettings ++ Sphinx.settings ++ Seq(
unmanagedSourceDirectories in Test <<= baseDirectory { _ ** "code" get },
libraryDependencies ++= Dependencies.docs,
2011-12-08 17:05:01 +13:00
unmanagedSourceDirectories in ScalariformKeys.format in Test <<= unmanagedSourceDirectories in Test
)
)
2011-07-04 19:16:43 +12:00
// Settings
override lazy val settings = super.settings ++ buildSettings ++ Seq(
resolvers += "Sonatype Snapshot Repo" at "https://oss.sonatype.org/content/repositories/snapshots/",
2012-04-23 11:57:13 +02:00
shellPrompt := { s => Project.extract(s).currentProject.id + " > " }
)
2011-07-08 18:01:19 +12:00
2011-07-26 17:49:08 +12:00
lazy val baseSettings = Defaults.defaultSettings ++ Publish.settings
2011-07-08 18:01:19 +12:00
lazy val parentSettings = baseSettings ++ Seq(
publishArtifact in Compile := false
2011-07-04 19:16:43 +12:00
)
val excludeTestNames = SettingKey[Seq[String]]("exclude-test-names")
val excludeTestTags = SettingKey[Seq[String]]("exclude-test-tags")
val includeTestTags = SettingKey[Seq[String]]("include-test-tags")
2011-07-14 14:10:37 +12:00
val defaultExcludedTags = Seq("timing", "long-running")
2011-07-14 14:10:37 +12:00
lazy val defaultMultiJvmOptions: Seq[String] = {
2012-05-24 10:00:35 +02:00
(System.getProperty("akka.test.timefactor") match {
case null => Nil
case x => List("-Dakka.test.timefactor=" + x)
}) :::
(if (getBoolean("sbt.log.noformat")) List("-Dakka.test.nocolor=true") else Nil)
}
// for excluding tests by name (or use system property: -Dakka.test.names.exclude=TimingSpec)
lazy val defaultExcludeTestNames: Seq[String] = {
val exclude = System.getProperty("akka.test.names.exclude", "")
if (exclude.isEmpty) Seq.empty else exclude.split(",").toSeq
}
// for excluding tests by tag (or use system property: -Dakka.test.tags.exclude=timing)
lazy val defaultExcludeTestTags: Seq[String] = {
val exclude = System.getProperty("akka.test.tags.exclude", "")
if (exclude.isEmpty) defaultExcludedTags else exclude.split(",").toSeq
}
// for including tests by tag (or use system property: -Dakka.test.tags.include=timing)
lazy val defaultIncludeTestTags: Seq[String] = {
val include = System.getProperty("akka.test.tags.include", "")
if (include.isEmpty) Seq.empty else include.split(",").toSeq
}
lazy val defaultMultiJvmScalatestOptions: Seq[String] = {
val excludeTags = (defaultExcludeTestTags.toSet -- defaultIncludeTestTags.toSet).toSeq
Seq("-r", "org.scalatest.akka.QuietReporter") ++
(if (excludeTags.isEmpty) Seq.empty else Seq("-l", excludeTags.mkString(" "))) ++
(if (defaultIncludeTestTags.isEmpty) Seq.empty else Seq("-n", defaultIncludeTestTags.mkString(" ")))
}
2011-07-26 17:49:08 +12:00
lazy val defaultSettings = baseSettings ++ formatSettings ++ Seq(
2011-07-04 19:16:43 +12:00
resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/",
// compile options
scalacOptions ++= Seq("-encoding", "UTF-8", "-deprecation", "-unchecked") ++ (
if (true || (System getProperty "java.runtime.version" startsWith "1.7")) Seq() else Seq("-optimize")), // -optimize fails with jdk7
2011-07-04 19:16:43 +12:00
javacOptions ++= Seq("-Xlint:unchecked", "-Xlint:deprecation"),
ivyLoggingLevel in ThisBuild := UpdateLogging.Quiet,
parallelExecution in Test := System.getProperty("akka.parallelExecution", "false").toBoolean,
2011-07-14 14:10:37 +12:00
excludeTestNames := defaultExcludeTestNames,
excludeTestTags := defaultExcludeTestTags,
includeTestTags := defaultIncludeTestTags,
// add filters for tests excluded by name
testOptions in Test <++= excludeTestNames map { _.map(exclude => Tests.Filter(test => !test.contains(exclude))) },
// add arguments for tests excluded by tag - includes override excludes (opposite to scalatest)
testOptions in Test <++= (excludeTestTags, includeTestTags) map { (excludes, includes) =>
val tags = (excludes.toSet -- includes.toSet).toSeq
if (tags.isEmpty) Seq.empty else Seq(Tests.Argument("-l", tags.mkString(" ")))
},
// add arguments for tests included by tag
testOptions in Test <++= includeTestTags map { tags =>
if (tags.isEmpty) Seq.empty else Seq(Tests.Argument("-n", tags.mkString(" ")))
},
// show full stack traces
testOptions in Test += Tests.Argument("-oF")
2011-07-04 19:16:43 +12:00
)
2011-07-08 12:53:36 +12:00
2011-12-08 17:05:01 +13:00
lazy val formatSettings = ScalariformPlugin.scalariformSettings ++ Seq(
ScalariformKeys.preferences in Compile := formattingPreferences,
ScalariformKeys.preferences in Test := formattingPreferences
2011-07-26 17:49:08 +12:00
)
def formattingPreferences = {
import scalariform.formatter.preferences._
FormattingPreferences()
.setPreference(RewriteArrowSymbols, true)
.setPreference(AlignParameters, true)
.setPreference(AlignSingleLineCaseStatements, true)
}
2011-12-08 17:05:01 +13:00
lazy val multiJvmSettings = MultiJvmPlugin.settings ++ inConfig(MultiJvm)(ScalariformPlugin.scalariformSettings) ++ Seq(
compileInputs in MultiJvm <<= (compileInputs in MultiJvm) dependsOn (ScalariformKeys.format in MultiJvm),
ScalariformKeys.preferences in MultiJvm := formattingPreferences
2011-07-26 17:49:08 +12:00
)
2011-07-04 19:16:43 +12:00
}
// Dependencies
object Dependencies {
import Dependency._
val testkit = Seq(Test.scalatest, Test.junit)
2011-07-04 19:16:43 +12:00
val actorTests = Seq(
Test.junit, Test.scalatest, Test.commonsMath, Test.mockito,
2012-04-19 15:09:20 +02:00
Test.scalacheck, protobuf
)
2011-07-04 19:16:43 +12:00
val remote = Seq(
netty, protobuf, Test.junit, Test.scalatest,
Test.zookeeper, Test.log4j // needed for ZkBarrier in multi-jvm tests
)
2011-07-04 19:16:43 +12:00
val cluster = Seq(Test.junit, Test.scalatest)
val slf4j = Seq(slf4jApi, Test.logback)
2011-07-04 19:16:43 +12:00
2011-12-19 15:46:06 +13:00
val agent = Seq(scalaStm, Test.scalatest, Test.junit)
val transactor = Seq(scalaStm, Test.scalatest, Test.junit)
val mailboxes = Seq(Test.scalatest, Test.junit)
val fileMailbox = Seq(Test.commonsIo, Test.scalatest, Test.junit)
2011-07-04 19:16:43 +12:00
val kernel = Seq(Test.scalatest, Test.junit)
2011-07-16 10:38:17 +02:00
val camel = Seq(camelCore, Test.scalatest, Test.junit, Test.mockito)
val tutorials = Seq(Test.scalatest, Test.junit)
val docs = Seq(Test.scalatest, Test.junit, Test.specs2)
val zeroMQ = Seq(protobuf, Dependency.zeroMQ, Test.scalatest, Test.junit)
2011-07-04 19:16:43 +12:00
}
object Dependency {
// Versions
object V {
2011-08-26 17:25:18 +02:00
val Camel = "2.8.0"
2011-07-04 19:16:43 +12:00
val Logback = "0.9.28"
2012-01-19 18:08:13 +01:00
val Netty = "3.3.0.Final"
2011-07-04 19:16:43 +12:00
val Protobuf = "2.4.1"
val ScalaStm = "0.5"
2011-07-11 14:19:53 -06:00
val Scalatest = "1.6.1"
val Slf4j = "1.6.4"
2011-07-04 19:16:43 +12:00
}
// Compile
2011-08-26 17:25:18 +02:00
val camelCore = "org.apache.camel" % "camel-core" % V.Camel // ApacheV2
2012-01-19 18:08:13 +01:00
val netty = "io.netty" % "netty" % V.Netty // ApacheV2
2011-07-04 19:16:43 +12:00
val protobuf = "com.google.protobuf" % "protobuf-java" % V.Protobuf // New BSD
val scalaStm = "org.scala-tools" % "scala-stm_2.9.1" % V.ScalaStm // Modified BSD (Scala)
2011-07-04 19:16:43 +12:00
val slf4jApi = "org.slf4j" % "slf4j-api" % V.Slf4j // MIT
val zeroMQ = "org.zeromq" % "zeromq-scala-binding_2.9.1" % "0.0.6" // ApacheV2
2011-07-04 19:16:43 +12:00
// Runtime
object Runtime {
2011-07-16 10:38:17 +02:00
val logback = "ch.qos.logback" % "logback-classic" % V.Logback % "runtime" // MIT
}
2011-07-04 19:16:43 +12:00
// Test
object Test {
val commonsMath = "org.apache.commons" % "commons-math" % "2.1" % "test" // ApacheV2
val commonsIo = "commons-io" % "commons-io" % "2.0.1" % "test"// ApacheV2
val junit = "junit" % "junit" % "4.5" % "test" // Common Public License 1.0
val logback = "ch.qos.logback" % "logback-classic" % V.Logback % "test" // EPL 1.0 / LGPL 2.1
val mockito = "org.mockito" % "mockito-all" % "1.8.1" % "test" // MIT
val scalatest = "org.scalatest" % "scalatest_2.9.1" % V.Scalatest % "test" // ApacheV2
val scalacheck = "org.scala-tools.testing" % "scalacheck_2.9.1" % "1.9" % "test" // New BSD
val specs2 = "org.specs2" % "specs2_2.9.1" % "1.9" % "test" // Modified BSD / ApacheV2
val zookeeper = "org.apache.hadoop.zookeeper" % "zookeeper" % "3.4.0" % "test" // ApacheV2
val log4j = "log4j" % "log4j" % "1.2.14" % "test" // ApacheV2
2011-07-04 19:16:43 +12:00
}
}
// OSGi settings
object OSGi {
val actor = exports(Seq("akka*"))
val agent = exports(Seq("akka.agent.*"))
val camel = exports(Seq("akka.camel.*", "akka.camelexamples"))
val cluster = exports(Seq("akka.cluster.*"))
val fileMailbox = exports(Seq("akka.actor.mailbox.*"))
val mailboxesCommon = exports(Seq("akka.actor.mailbox.*"))
val remote = exports(Seq("akka.remote.*", "akka.routing.*", "akka.serialization.*"))
val slf4j = exports(Seq("akka.event.slf4j.*"))
val transactor = exports(Seq("akka.transactor.*"))
val zeroMQ = exports(Seq("akka.zeromq.*"))
def exports(packages: Seq[String]) = osgiSettings ++ Seq(
OsgiKeys.importPackage := Seq("!sun.misc", akkaImport(), configImport(), scalaImport(), "*"),
OsgiKeys.exportPackage := packages
)
def akkaImport(packageName: String = "akka.*") = "%s;version=\"[2.1,2.2)\"".format(packageName)
def configImport(packageName: String = "com.typesafe.config.*") = "%s;version=\"[0.4,0.5)\"".format(packageName)
def scalaImport(packageName: String = "scala.*") = "%s;version=\"[2.9.2,2.10)\"".format(packageName)
}