2019-01-02 18:55:26 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* Copyright (C) 2009-2019 Lightbend Inc. <https://www.lightbend.com>
|
2011-11-25 11:01:03 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
2011-09-23 10:21:03 +02:00
|
|
|
|
package akka
|
|
|
|
|
|
|
2018-12-05 16:30:21 +08:00
|
|
|
|
import java.io.{FileInputStream, InputStreamReader}
|
2012-12-18 12:10:59 +01:00
|
|
|
|
import java.util.Properties
|
2014-07-08 18:30:15 +02:00
|
|
|
|
|
|
|
|
|
|
import sbt.Keys._
|
2017-06-09 04:34:21 -07:00
|
|
|
|
import sbt._
|
2019-02-09 14:21:16 +01:00
|
|
|
|
import org.scalafmt.sbt.ScalafmtPlugin.autoImport._
|
2018-12-05 16:30:21 +08:00
|
|
|
|
|
2017-10-04 14:22:25 +02:00
|
|
|
|
import scala.collection.breakOut
|
2011-07-04 19:16:43 +12:00
|
|
|
|
|
2017-05-16 22:03:18 +02:00
|
|
|
|
object AkkaBuild {
|
2012-12-18 12:10:59 +01:00
|
|
|
|
|
2015-04-30 09:23:18 +02:00
|
|
|
|
val enableMiMa = true
|
2012-06-28 15:33:49 +02:00
|
|
|
|
|
2016-05-10 10:49:33 +02:00
|
|
|
|
val parallelExecutionByDefault = false // TODO: enable this once we're sure it does not break things
|
2015-05-05 19:39:56 +02:00
|
|
|
|
|
2015-05-21 21:07:37 +02:00
|
|
|
|
lazy val buildSettings = Dependencies.Versions ++ Seq(
|
2017-10-06 10:30:28 +02:00
|
|
|
|
organization := "com.typesafe.akka",
|
2018-04-05 14:50:24 +03:00
|
|
|
|
// use the same value as in the build scope, so it can be overriden by stampVersion
|
|
|
|
|
|
version := (version in ThisBuild).value)
|
2011-07-04 19:16:43 +12:00
|
|
|
|
|
2017-10-30 03:13:14 +02:00
|
|
|
|
lazy val rootSettings = Release.settings ++
|
2016-02-21 09:08:34 +05:00
|
|
|
|
UnidocRoot.akkaSettings ++
|
|
|
|
|
|
Protobuf.settings ++ Seq(
|
2018-04-05 14:50:24 +03:00
|
|
|
|
parallelExecution in GlobalScope := System.getProperty("akka.parallelExecution", parallelExecutionByDefault.toString).toBoolean,
|
|
|
|
|
|
version in ThisBuild := "2.5-SNAPSHOT"
|
|
|
|
|
|
)
|
2016-03-10 10:45:35 +02:00
|
|
|
|
|
2017-02-20 12:05:21 +01:00
|
|
|
|
lazy val mayChangeSettings = Seq(
|
2012-09-27 15:57:46 +02:00
|
|
|
|
description := """|This module of Akka is marked as
|
2017-02-20 12:05:21 +01:00
|
|
|
|
|'may change', which means that it is in early
|
2012-09-27 15:57:46 +02:00
|
|
|
|
|access mode, which also means that it is not covered
|
2017-02-20 12:05:21 +01:00
|
|
|
|
|by commercial support. An module marked 'may change' doesn't
|
2012-09-27 15:57:46 +02:00
|
|
|
|
|have to obey the rule of staying binary compatible
|
|
|
|
|
|
|between minor releases. Breaking API changes may be
|
|
|
|
|
|
|introduced in minor releases without notice as we
|
2017-02-20 12:05:21 +01:00
|
|
|
|
|refine and simplify based on your feedback. Additionally
|
|
|
|
|
|
|such a module may be dropped in major releases
|
2012-09-27 15:57:46 +02:00
|
|
|
|
|without prior deprecation.
|
2017-10-06 10:30:28 +02:00
|
|
|
|
|""".stripMargin)
|
2012-09-27 15:57:46 +02:00
|
|
|
|
|
2014-02-06 08:56:08 +01:00
|
|
|
|
val (mavenLocalResolver, mavenLocalResolverSettings) =
|
|
|
|
|
|
System.getProperty("akka.build.M2Dir") match {
|
2017-10-06 10:30:28 +02:00
|
|
|
|
case null ⇒ (Resolver.mavenLocal, Seq.empty)
|
|
|
|
|
|
case path ⇒
|
2014-02-06 08:56:08 +01:00
|
|
|
|
// Maven resolver settings
|
2017-10-30 03:13:14 +02:00
|
|
|
|
def deliverPattern(outputPath: File): String =
|
|
|
|
|
|
(outputPath / "[artifact]-[revision](-[classifier]).[ext]").absolutePath
|
|
|
|
|
|
|
2014-02-06 08:56:08 +01:00
|
|
|
|
val resolver = Resolver.file("user-publish-m2-local", new File(path))
|
|
|
|
|
|
(resolver, Seq(
|
2017-10-06 10:30:28 +02:00
|
|
|
|
otherResolvers := resolver :: publishTo.value.toList,
|
2017-10-30 03:13:14 +02:00
|
|
|
|
publishM2Configuration := Classpaths.publishConfig(
|
|
|
|
|
|
publishMavenStyle.value,
|
|
|
|
|
|
deliverPattern(crossTarget.value),
|
|
|
|
|
|
if (isSnapshot.value) "integration" else "release",
|
|
|
|
|
|
ivyConfigurations.value.map(c => ConfigRef(c.name)).toVector,
|
|
|
|
|
|
artifacts = packagedArtifacts.value.toVector,
|
|
|
|
|
|
resolverName = resolver.name,
|
|
|
|
|
|
checksums = checksums.in(publishM2).value.toVector,
|
|
|
|
|
|
logging = ivyLoggingLevel.value,
|
|
|
|
|
|
overwrite = true)))
|
2014-02-06 08:56:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-12-03 09:18:26 +01:00
|
|
|
|
lazy val resolverSettings = {
|
|
|
|
|
|
// should we be allowed to use artifacts published to the local maven repository
|
2017-10-06 10:30:28 +02:00
|
|
|
|
if (System.getProperty("akka.build.useLocalMavenResolver", "false").toBoolean)
|
2014-02-06 08:56:08 +01:00
|
|
|
|
Seq(resolvers += mavenLocalResolver)
|
2013-12-03 09:18:26 +01:00
|
|
|
|
else Seq.empty
|
|
|
|
|
|
} ++ {
|
|
|
|
|
|
// should we be allowed to use artifacts from sonatype snapshots
|
2017-10-06 10:30:28 +02:00
|
|
|
|
if (System.getProperty("akka.build.useSnapshotSonatypeResolver", "false").toBoolean)
|
2013-12-03 09:18:26 +01:00
|
|
|
|
Seq(resolvers += Resolver.sonatypeRepo("snapshots"))
|
|
|
|
|
|
else Seq.empty
|
2014-02-28 10:12:29 +01:00
|
|
|
|
} ++ Seq(
|
2017-10-06 10:30:28 +02:00
|
|
|
|
pomIncludeRepository := (_ ⇒ false) // do not leak internal repositories during staging
|
2014-02-28 10:12:29 +01:00
|
|
|
|
)
|
2013-12-03 09:18:26 +01:00
|
|
|
|
|
2015-01-30 18:34:03 +01:00
|
|
|
|
private def allWarnings: Boolean = System.getProperty("akka.allwarnings", "false").toBoolean
|
2015-01-30 11:33:33 +01:00
|
|
|
|
|
2019-03-01 13:39:08 +01:00
|
|
|
|
final val DefaultScalacOptions = Seq("-encoding", "UTF-8", "-feature", "-unchecked", "-Xlog-reflective-calls")
|
2018-07-02 16:38:07 +02:00
|
|
|
|
|
|
|
|
|
|
// -XDignore.symbol.file suppresses sun.misc.Unsafe warnings
|
|
|
|
|
|
final val DefaultJavacOptions = Seq("-encoding", "UTF-8", "-Xlint:unchecked", "-XDignore.symbol.file")
|
|
|
|
|
|
|
2016-01-13 12:00:46 +01:00
|
|
|
|
lazy val defaultSettings = resolverSettings ++
|
|
|
|
|
|
TestExtras.Filter.settings ++
|
2017-10-15 18:01:54 +02:00
|
|
|
|
Protobuf.settings ++ Seq[Setting[_]](
|
2017-10-06 10:30:28 +02:00
|
|
|
|
// compile options
|
2018-07-02 16:38:07 +02:00
|
|
|
|
scalacOptions in Compile ++= DefaultScalacOptions,
|
|
|
|
|
|
// Makes sure that, even when compiling with a jdk version greater than 8, the resulting jar will not refer to
|
|
|
|
|
|
// methods not found in jdk8. To test whether this has the desired effect, compile akka-remote and check the
|
|
|
|
|
|
// invocation of 'ByteBuffer.clear()' in EnvelopeBuffer.class with 'javap -c': it should refer to
|
|
|
|
|
|
// "java/nio/ByteBuffer.clear:()Ljava/nio/Buffer" and not "java/nio/ByteBuffer.clear:()Ljava/nio/ByteBuffer":
|
2018-07-30 13:44:11 +02:00
|
|
|
|
scalacOptions in Compile ++= (
|
2018-11-26 13:53:58 +01:00
|
|
|
|
if (System.getProperty("java.version").startsWith("1."))
|
|
|
|
|
|
Seq("-target:jvm-1.8")
|
2018-07-30 13:44:11 +02:00
|
|
|
|
else
|
2018-11-22 13:01:33 +01:00
|
|
|
|
if (scalaBinaryVersion.value == "2.11")
|
|
|
|
|
|
Seq("-target:jvm-1.8", "-javabootclasspath", CrossJava.Keys.fullJavaHomes.value("8") + "/jre/lib/rt.jar")
|
|
|
|
|
|
else
|
|
|
|
|
|
// -release 8 is not enough, for some reason we need the 8 rt.jar explicitly #25330
|
|
|
|
|
|
Seq("-release", "8", "-javabootclasspath", CrossJava.Keys.fullJavaHomes.value("8") + "/jre/lib/rt.jar")),
|
2017-10-06 10:30:28 +02:00
|
|
|
|
scalacOptions in Compile ++= (if (allWarnings) Seq("-deprecation") else Nil),
|
|
|
|
|
|
scalacOptions in Test := (scalacOptions in Test).value.filterNot(opt ⇒
|
2019-03-01 13:39:08 +01:00
|
|
|
|
opt == "-Xlog-reflective-calls" || opt.contains("genjavadoc")),
|
2018-11-22 13:01:33 +01:00
|
|
|
|
javacOptions in compile ++= DefaultJavacOptions ++ (
|
|
|
|
|
|
if (System.getProperty("java.version").startsWith("1."))
|
|
|
|
|
|
Seq()
|
|
|
|
|
|
else
|
|
|
|
|
|
Seq("-source", "8", "-target", "8", "-bootclasspath", CrossJava.Keys.fullJavaHomes.value("8") + "/jre/lib/rt.jar")
|
|
|
|
|
|
),
|
|
|
|
|
|
javacOptions in test ++= DefaultJavacOptions ++ (
|
|
|
|
|
|
if (System.getProperty("java.version").startsWith("1."))
|
|
|
|
|
|
Seq()
|
|
|
|
|
|
else
|
|
|
|
|
|
Seq("-source", "8", "-target", "8", "-bootclasspath", CrossJava.Keys.fullJavaHomes.value("8") + "/jre/lib/rt.jar")
|
|
|
|
|
|
),
|
2017-10-06 10:30:28 +02:00
|
|
|
|
javacOptions in compile ++= (if (allWarnings) Seq("-Xlint:deprecation") else Nil),
|
|
|
|
|
|
javacOptions in doc ++= Seq(),
|
2011-07-04 19:16:43 +12:00
|
|
|
|
|
2017-10-06 10:30:28 +02:00
|
|
|
|
crossVersion := CrossVersion.binary,
|
2012-08-22 15:52:32 +02:00
|
|
|
|
|
2018-08-02 17:39:44 +02:00
|
|
|
|
// Adds a `src/main/scala-2.13+` source directory for Scala 2.13 and newer
|
|
|
|
|
|
// and a `src/main/scala-2.13-` source directory for Scala version older than 2.13
|
|
|
|
|
|
unmanagedSourceDirectories in Compile += {
|
|
|
|
|
|
val sourceDir = (sourceDirectory in Compile).value
|
|
|
|
|
|
CrossVersion.partialVersion(scalaVersion.value) match {
|
|
|
|
|
|
case Some((2, n)) if n >= 13 => sourceDir / "scala-2.13+"
|
|
|
|
|
|
case _ => sourceDir / "scala-2.13-"
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2017-10-06 10:30:28 +02:00
|
|
|
|
ivyLoggingLevel in ThisBuild := UpdateLogging.Quiet,
|
2012-01-12 13:45:53 +01:00
|
|
|
|
|
2017-10-06 10:30:28 +02:00
|
|
|
|
licenses := Seq(("Apache License, Version 2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))),
|
|
|
|
|
|
homepage := Some(url("http://akka.io/")),
|
2012-09-24 11:52:02 +02:00
|
|
|
|
|
2017-10-06 10:30:28 +02:00
|
|
|
|
apiURL := Some(url(s"http://doc.akka.io/api/akka/${version.value}")),
|
2016-10-27 12:29:15 +03:00
|
|
|
|
|
2017-10-06 10:30:28 +02:00
|
|
|
|
initialCommands :=
|
|
|
|
|
|
"""|import language.postfixOps
|
2013-03-06 09:44:34 +01:00
|
|
|
|
|import akka.actor._
|
|
|
|
|
|
|import ActorDSL._
|
|
|
|
|
|
|import scala.concurrent._
|
|
|
|
|
|
|import com.typesafe.config.ConfigFactory
|
|
|
|
|
|
|import scala.concurrent.duration._
|
|
|
|
|
|
|import akka.util.Timeout
|
2013-03-07 19:59:59 +01:00
|
|
|
|
|var config = ConfigFactory.parseString("akka.stdout-loglevel=INFO,akka.loglevel=DEBUG,pinned{type=PinnedDispatcher,executor=thread-pool-executor,throughput=1000}")
|
2016-09-29 15:01:05 +02:00
|
|
|
|
|var remoteConfig = ConfigFactory.parseString("akka.remote.netty{port=0,use-dispatcher-for-io=akka.actor.default-dispatcher,execution-pool-size=0},akka.actor.provider=remote").withFallback(config)
|
2013-03-06 09:44:34 +01:00
|
|
|
|
|var system: ActorSystem = null
|
|
|
|
|
|
|implicit def _system = system
|
2014-08-25 15:49:28 +02:00
|
|
|
|
|def startSystem(remoting: Boolean = false) { system = ActorSystem("repl", if(remoting) remoteConfig else config); println("don’t forget to system.terminate()!") }
|
2013-03-06 09:44:34 +01:00
|
|
|
|
|implicit def ec = system.dispatcher
|
|
|
|
|
|
|implicit val timeout = Timeout(5 seconds)
|
|
|
|
|
|
|""".stripMargin,
|
|
|
|
|
|
|
2017-10-06 10:30:28 +02:00
|
|
|
|
/**
|
|
|
|
|
|
* Test settings
|
|
|
|
|
|
*/
|
|
|
|
|
|
fork in Test := true,
|
|
|
|
|
|
|
|
|
|
|
|
// default JVM config for tests
|
|
|
|
|
|
javaOptions in Test ++= {
|
|
|
|
|
|
val defaults = Seq(
|
|
|
|
|
|
// ## core memory settings
|
|
|
|
|
|
"-XX:+UseG1GC",
|
|
|
|
|
|
// most tests actually don't really use _that_ much memory (>1g usually)
|
|
|
|
|
|
// twice used (and then some) keeps G1GC happy - very few or to no full gcs
|
|
|
|
|
|
"-Xms3g", "-Xmx3g",
|
|
|
|
|
|
// increase stack size (todo why?)
|
|
|
|
|
|
"-Xss2m",
|
|
|
|
|
|
|
|
|
|
|
|
// ## extra memory/gc tuning
|
|
|
|
|
|
// this breaks jstat, but could avoid costly syncs to disc see http://www.evanjones.ca/jvm-mmap-pause.html
|
|
|
|
|
|
"-XX:+PerfDisableSharedMem",
|
|
|
|
|
|
// tell G1GC that we would be really happy if all GC pauses could be kept below this as higher would
|
|
|
|
|
|
// likely start causing test failures in timing tests
|
|
|
|
|
|
"-XX:MaxGCPauseMillis=300",
|
|
|
|
|
|
// nio direct memory limit for artery/aeron (probably)
|
|
|
|
|
|
"-XX:MaxDirectMemorySize=256m",
|
|
|
|
|
|
|
|
|
|
|
|
// faster random source
|
|
|
|
|
|
"-Djava.security.egd=file:/dev/./urandom")
|
|
|
|
|
|
|
|
|
|
|
|
if (sys.props.contains("akka.ci-server"))
|
|
|
|
|
|
defaults ++ Seq("-XX:+PrintGCTimeStamps", "-XX:+PrintGCDetails")
|
|
|
|
|
|
else
|
|
|
|
|
|
defaults
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// all system properties passed to sbt prefixed with "akka." will be passed on to the forked jvms as is
|
|
|
|
|
|
javaOptions in Test := {
|
|
|
|
|
|
val base = (javaOptions in Test).value
|
|
|
|
|
|
val akkaSysProps: Seq[String] =
|
|
|
|
|
|
sys.props.filter(_._1.startsWith("akka"))
|
|
|
|
|
|
.map { case (key, value) ⇒ s"-D$key=$value" }(breakOut)
|
|
|
|
|
|
|
|
|
|
|
|
base ++ akkaSysProps
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// with forked tests the working directory is set to each module's home directory
|
|
|
|
|
|
// rather than the Akka root, some tests depend on Akka root being working dir, so reset
|
|
|
|
|
|
testGrouping in Test := {
|
|
|
|
|
|
val original: Seq[Tests.Group] = (testGrouping in Test).value
|
|
|
|
|
|
|
|
|
|
|
|
original.map { group ⇒
|
|
|
|
|
|
group.runPolicy match {
|
|
|
|
|
|
case Tests.SubProcess(forkOptions) ⇒
|
2017-10-30 03:13:14 +02:00
|
|
|
|
group.copy(runPolicy = Tests.SubProcess(forkOptions.withWorkingDirectory(
|
2017-10-06 10:30:28 +02:00
|
|
|
|
workingDirectory = Some(new File(System.getProperty("user.dir"))))))
|
|
|
|
|
|
case _ ⇒ group
|
|
|
|
|
|
}
|
2017-10-04 14:22:25 +02:00
|
|
|
|
}
|
2017-10-06 10:30:28 +02:00
|
|
|
|
},
|
2014-04-25 16:32:43 +02:00
|
|
|
|
|
2017-10-06 10:30:28 +02:00
|
|
|
|
parallelExecution in Test := System.getProperty("akka.parallelExecution", parallelExecutionByDefault.toString).toBoolean,
|
|
|
|
|
|
logBuffered in Test := System.getProperty("akka.logBufferedTests", "false").toBoolean,
|
2017-10-04 14:22:25 +02:00
|
|
|
|
|
2017-10-06 10:30:28 +02:00
|
|
|
|
// show full stack traces and test case durations
|
2017-10-15 18:01:54 +02:00
|
|
|
|
testOptions in Test += Tests.Argument("-oDF")) ++
|
2017-10-06 10:30:28 +02:00
|
|
|
|
mavenLocalResolverSettings ++
|
2018-07-02 16:38:07 +02:00
|
|
|
|
docLintingSettings ++
|
|
|
|
|
|
CrossJava.crossJavaSettings
|
2016-01-13 12:00:46 +01:00
|
|
|
|
|
|
|
|
|
|
lazy val docLintingSettings = Seq(
|
2017-10-06 10:30:28 +02:00
|
|
|
|
javacOptions in compile ++= Seq("-Xdoclint:none"),
|
|
|
|
|
|
javacOptions in test ++= Seq("-Xdoclint:none"),
|
2019-01-28 08:04:09 +01:00
|
|
|
|
javacOptions in doc ++= Seq("-Xdoclint:none", "--ignore-source-errors"))
|
2011-07-08 12:53:36 +12:00
|
|
|
|
|
2019-02-21 15:47:09 +01:00
|
|
|
|
|
|
|
|
|
|
lazy val noScala211 = Seq(
|
|
|
|
|
|
crossScalaVersions := crossScalaVersions.value.filterNot(_.startsWith("2.11"))
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2012-12-18 12:10:59 +01:00
|
|
|
|
def loadSystemProperties(fileName: String): Unit = {
|
|
|
|
|
|
import scala.collection.JavaConverters._
|
|
|
|
|
|
val file = new File(fileName)
|
|
|
|
|
|
if (file.exists()) {
|
|
|
|
|
|
println("Loading system properties from file `" + fileName + "`")
|
|
|
|
|
|
val in = new InputStreamReader(new FileInputStream(file), "UTF-8")
|
|
|
|
|
|
val props = new Properties
|
|
|
|
|
|
props.load(in)
|
|
|
|
|
|
in.close()
|
|
|
|
|
|
sys.props ++ props.asScala
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-06 10:30:28 +02:00
|
|
|
|
def majorMinor(version: String): Option[String] = """\d+\.\d+""".r.findFirstIn(version)
|
2011-07-04 19:16:43 +12:00
|
|
|
|
}
|