pekko/project/AkkaBuild.scala

183 lines
7.3 KiB
Scala
Raw Normal View History

/**
2017-01-04 17:37:10 +01:00
* Copyright (C) 2009-2017 Lightbend Inc. <http://www.lightbend.com>
*/
2011-09-23 10:21:03 +02:00
package akka
2017-05-16 21:17:11 +02:00
import java.io.{FileInputStream, InputStreamReader}
import java.util.Properties
import akka.TestExtras.JUnitFileReporting
2017-05-16 21:17:11 +02:00
import com.typesafe.sbt.pgp.PgpKeys.publishSigned
import sbt.Keys._
2017-05-16 21:17:11 +02:00
import sbt.{TestResult, _}
2011-07-04 19:16:43 +12:00
object AkkaBuild {
val enableMiMa = true
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-21 21:07:37 +02:00
lazy val buildSettings = Dependencies.Versions ++ Seq(
organization := "com.typesafe.akka",
version := "2.5-SNAPSHOT"
2011-07-08 18:01:19 +12:00
)
2011-07-04 19:16:43 +12:00
lazy val rootSettings = parentSettings ++ Release.settings ++
UnidocRoot.akkaSettings ++
Protobuf.settings ++ Seq(
parallelExecution in GlobalScope := System.getProperty("akka.parallelExecution", parallelExecutionByDefault.toString).toBoolean
)
val dontPublishSettings = Seq(
publishSigned := (),
publish := (),
publishArtifact in Compile := false
)
val dontPublishDocsSettings = Seq(
sources in doc in Compile := List()
)
2011-07-08 18:01:19 +12:00
lazy val parentSettings = Seq(
publishArtifact := false
) ++ dontPublishSettings
2011-07-04 19:16:43 +12:00
lazy val mayChangeSettings = Seq(
description := """|This module of Akka is marked as
|'may change', which means that it is in early
|access mode, which also means that it is not covered
|by commercial support. An module marked 'may change' doesn't
|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
|refine and simplify based on your feedback. Additionally
|such a module may be dropped in major releases
|without prior deprecation.
|""".stripMargin
)
val (mavenLocalResolver, mavenLocalResolverSettings) =
System.getProperty("akka.build.M2Dir") match {
case null => (Resolver.mavenLocal, Seq.empty)
case path =>
// Maven resolver settings
val resolver = Resolver.file("user-publish-m2-local", new File(path))
(resolver, Seq(
otherResolvers := resolver:: publishTo.value.toList,
2017-05-16 21:17:11 +02:00
publishM2Configuration := Classpaths.publishConfig(packagedArtifacts.value, None, resolverName = resolver.name, checksums = checksums.in(publishM2).value, logging = ivyLoggingLevel.value, overwrite = true)
))
}
lazy val resolverSettings = {
// should we be allowed to use artifacts published to the local maven repository
if(System.getProperty("akka.build.useLocalMavenResolver", "false").toBoolean)
Seq(resolvers += mavenLocalResolver)
else Seq.empty
} ++ {
// should we be allowed to use artifacts from sonatype snapshots
if(System.getProperty("akka.build.useSnapshotSonatypeResolver", "false").toBoolean)
Seq(resolvers += Resolver.sonatypeRepo("snapshots"))
else Seq.empty
} ++ Seq(
pomIncludeRepository := (_ => false) // do not leak internal repositories during staging
)
private def allWarnings: Boolean = System.getProperty("akka.allwarnings", "false").toBoolean
2015-01-30 11:33:33 +01:00
2016-01-13 12:00:46 +01:00
lazy val defaultSettings = resolverSettings ++
TestExtras.Filter.settings ++
Protobuf.settings ++ Seq(
2011-07-04 19:16:43 +12:00
// compile options
scalacOptions in Compile ++= Seq("-encoding", "UTF-8", "-target:jvm-1.8", "-feature", "-unchecked", "-Xlog-reflective-calls", "-Xlint"),
scalacOptions in Compile ++= (if (allWarnings) Seq("-deprecation") else Nil),
2015-05-20 09:00:21 +02:00
scalacOptions in Test := (scalacOptions in Test).value.filterNot(opt =>
opt == "-Xlog-reflective-calls" || opt.contains("genjavadoc")),
2015-01-30 16:05:36 +01:00
// -XDignore.symbol.file suppresses sun.misc.Unsafe warnings
javacOptions in compile ++= Seq("-encoding", "UTF-8", "-source", "1.8", "-target", "1.8", "-Xlint:unchecked", "-XDignore.symbol.file"),
javacOptions in compile ++= (if (allWarnings) Seq("-Xlint:deprecation") else Nil),
2016-01-13 12:00:46 +01:00
javacOptions in doc ++= Seq(),
incOptions := incOptions.value.withNameHashing(true),
2011-07-04 19:16:43 +12:00
crossVersion := CrossVersion.binary,
ivyLoggingLevel in ThisBuild := UpdateLogging.Quiet,
licenses := Seq(("Apache License, Version 2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))),
homepage := Some(url("http://akka.io/")),
apiURL := Some(url(s"http://doc.akka.io/api/akka/${version.value}")),
initialCommands :=
"""|import language.postfixOps
|import akka.actor._
|import ActorDSL._
|import scala.concurrent._
|import com.typesafe.config.ConfigFactory
|import scala.concurrent.duration._
|import akka.util.Timeout
|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)
|var system: ActorSystem = null
|implicit def _system = system
|def startSystem(remoting: Boolean = false) { system = ActorSystem("repl", if(remoting) remoteConfig else config); println("dont forget to system.terminate()!") }
|implicit def ec = system.dispatcher
|implicit val timeout = Timeout(5 seconds)
|""".stripMargin,
/**
* Test settings
*/
parallelExecution in Test := System.getProperty("akka.parallelExecution", parallelExecutionByDefault.toString).toBoolean,
logBuffered in Test := System.getProperty("akka.logBufferedTests", "false").toBoolean,
2011-07-14 14:10:37 +12:00
// show full stack traces and test case durations
testOptions in Test += Tests.Argument("-oDF"),
2013-10-18 14:13:23 +02:00
// don't save test output to a file
2017-05-16 21:17:11 +02:00
testListeners in (Test, test) := {
val log = streams.value.log
Seq(new TestsListener {
def doInit(): Unit = ()
def doComplete(finalResult: TestResult.Value): Unit = ()
def startGroup(name: String): Unit = ()
def testEvent(event: TestEvent): Unit = ()
def endGroup(name: String, t: Throwable): Unit = {
log.trace(t)
log.error("Could not run test " + name + ": " + t.toString)
}
def endGroup(name: String, result: TestResult.Value): Unit = ()
})
},
2014-04-25 16:32:43 +02:00
// -v Log "test run started" / "test started" / "test run finished" events on log level "info" instead of "debug".
// -a Show stack traces and exception class name for AssertionErrors.
testOptions += Tests.Argument(TestFrameworks.JUnit, "-v", "-a")
) ++
mavenLocalResolverSettings ++
2016-01-13 12:00:46 +01:00
JUnitFileReporting.settings ++
docLintingSettings
lazy val docLintingSettings = Seq(
javacOptions in compile ++= Seq("-Xdoclint:none"),
javacOptions in test ++= Seq("-Xdoclint:none"),
javacOptions in doc ++= Seq("-Xdoclint:none")
)
2011-07-08 12:53:36 +12: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
}
}
2011-07-04 19:16:43 +12:00
}