From 82ca8a2cc73f26005e161692b70edd33df7577f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Mickevi=C4=8Dius?= Date: Mon, 30 Oct 2017 03:13:14 +0200 Subject: [PATCH] Port build to SBT 1.x (#23850) * Port build to SBT 1.x * Fix multinode tests, always enable genjavadoc bootstrap --- akka-actor-tests/build.sbt | 8 - akka-actor/build.sbt | 13 - akka-agent/build.sbt | 8 - akka-bench-jmh/build.sbt | 12 - akka-camel/build.sbt | 6 - akka-cluster-metrics/build.sbt | 12 - akka-cluster-sharding/build.sbt | 8 - akka-cluster-tools/build.sbt | 8 - akka-cluster/build.sbt | 12 - akka-contrib/build.sbt | 20 -- akka-distributed-data/build.sbt | 8 - akka-docs/build.sbt | 55 ----- akka-multi-node-testkit/build.sbt | 5 - akka-osgi/build.sbt | 8 - akka-persistence-query/build.sbt | 10 - akka-persistence-shared/build.sbt | 10 - akka-persistence-tck/build.sbt | 10 - akka-persistence/build.sbt | 8 - akka-protobuf/build.sbt | 8 - akka-remote-tests/build.sbt | 14 -- akka-remote/build.sbt | 8 - akka-slf4j/build.sbt | 6 - akka-stream-testkit/build.sbt | 6 - akka-stream-tests-tck/build.sbt | 14 -- akka-stream-tests/build.sbt | 8 - akka-stream/build.sbt | 8 - akka-testkit/build.sbt | 8 - akka-typed-testkit/build.sbt | 6 - akka-typed-tests/build.sbt | 8 - akka-typed/build.sbt | 16 -- build.sbt | 233 ++++++++++++++++-- project/AkkaBuild.scala | 31 ++- project/Dependencies.scala | 2 +- project/Doc.scala | 36 ++- project/MiMa.scala | 6 +- project/MultiNode.scala | 9 + project/ParadoxBrowse.scala | 27 ++ project/Protobuf.scala | 55 ++++- project/Publish.scala | 22 +- project/Release.scala | 4 +- project/ValidatePullRequest.scala | 133 +++++----- .../{Version.scala => VersionGenerator.scala} | 4 +- project/build.properties | 2 +- project/plugins.sbt | 43 +--- 44 files changed, 443 insertions(+), 495 deletions(-) delete mode 100644 akka-actor-tests/build.sbt delete mode 100644 akka-actor/build.sbt delete mode 100644 akka-agent/build.sbt delete mode 100644 akka-bench-jmh/build.sbt delete mode 100644 akka-camel/build.sbt delete mode 100644 akka-cluster-metrics/build.sbt delete mode 100644 akka-cluster-sharding/build.sbt delete mode 100644 akka-cluster-tools/build.sbt delete mode 100644 akka-cluster/build.sbt delete mode 100644 akka-contrib/build.sbt delete mode 100644 akka-distributed-data/build.sbt delete mode 100644 akka-docs/build.sbt delete mode 100644 akka-multi-node-testkit/build.sbt delete mode 100644 akka-osgi/build.sbt delete mode 100644 akka-persistence-query/build.sbt delete mode 100644 akka-persistence-shared/build.sbt delete mode 100644 akka-persistence-tck/build.sbt delete mode 100644 akka-persistence/build.sbt delete mode 100644 akka-protobuf/build.sbt delete mode 100644 akka-remote-tests/build.sbt delete mode 100644 akka-remote/build.sbt delete mode 100644 akka-slf4j/build.sbt delete mode 100644 akka-stream-testkit/build.sbt delete mode 100644 akka-stream-tests-tck/build.sbt delete mode 100644 akka-stream-tests/build.sbt delete mode 100644 akka-stream/build.sbt delete mode 100644 akka-testkit/build.sbt delete mode 100644 akka-typed-testkit/build.sbt delete mode 100644 akka-typed-tests/build.sbt delete mode 100644 akka-typed/build.sbt create mode 100644 project/ParadoxBrowse.scala rename project/{Version.scala => VersionGenerator.scala} (91%) diff --git a/akka-actor-tests/build.sbt b/akka-actor-tests/build.sbt deleted file mode 100644 index e890cf43a3..0000000000 --- a/akka-actor-tests/build.sbt +++ /dev/null @@ -1,8 +0,0 @@ -import akka.{ AkkaBuild, Dependencies, Formatting } - -AkkaBuild.defaultSettings -AkkaBuild.dontPublishSettings -Formatting.formatSettings -Dependencies.actorTests - -disablePlugins(MimaPlugin) diff --git a/akka-actor/build.sbt b/akka-actor/build.sbt deleted file mode 100644 index 025b0daa28..0000000000 --- a/akka-actor/build.sbt +++ /dev/null @@ -1,13 +0,0 @@ -import akka.{ AkkaBuild, Formatting, OSGi, Dependencies, Version } - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.actor -Dependencies.actor -Version.versionSettings -unmanagedSourceDirectories in Compile += { - val ver = scalaVersion.value.take(4) - (scalaSource in Compile).value.getParentFile / s"scala-$ver" -} - -enablePlugins(spray.boilerplate.BoilerplatePlugin) diff --git a/akka-agent/build.sbt b/akka-agent/build.sbt deleted file mode 100644 index 7ea13b351e..0000000000 --- a/akka-agent/build.sbt +++ /dev/null @@ -1,8 +0,0 @@ -import akka.{ AkkaBuild, Dependencies, Formatting, OSGi, ScaladocNoVerificationOfDiagrams } - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.agent -Dependencies.agent - -enablePlugins(ScaladocNoVerificationOfDiagrams) diff --git a/akka-bench-jmh/build.sbt b/akka-bench-jmh/build.sbt deleted file mode 100644 index 92183e8c41..0000000000 --- a/akka-bench-jmh/build.sbt +++ /dev/null @@ -1,12 +0,0 @@ -import akka._ -import com.typesafe.sbt.pgp.PgpKeys.publishSigned - -enablePlugins(JmhPlugin, ScaladocNoVerificationOfDiagrams) -disablePlugins(Unidoc, MimaPlugin) - -AkkaBuild.defaultSettings -Formatting.formatSettings - -AkkaBuild.dontPublishSettings -AkkaBuild.dontPublishDocsSettings -Dependencies.benchJmh diff --git a/akka-camel/build.sbt b/akka-camel/build.sbt deleted file mode 100644 index ac94d8d585..0000000000 --- a/akka-camel/build.sbt +++ /dev/null @@ -1,6 +0,0 @@ -import akka.{ AkkaBuild, Dependencies, Formatting, OSGi } - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.camel -Dependencies.camel diff --git a/akka-cluster-metrics/build.sbt b/akka-cluster-metrics/build.sbt deleted file mode 100644 index 2f95a27041..0000000000 --- a/akka-cluster-metrics/build.sbt +++ /dev/null @@ -1,12 +0,0 @@ -import akka.{ AkkaBuild, Dependencies, Formatting, OSGi, MultiNodeScalaTest, SigarLoader } -import com.typesafe.sbt.SbtMultiJvm.MultiJvmKeys._ - -AkkaBuild.defaultSettings -Formatting.formatSettings -SigarLoader.sigarSettings -OSGi.clusterMetrics -Dependencies.clusterMetrics - -parallelExecution in Test := false - -enablePlugins(MultiNodeScalaTest) diff --git a/akka-cluster-sharding/build.sbt b/akka-cluster-sharding/build.sbt deleted file mode 100644 index 097d5847f4..0000000000 --- a/akka-cluster-sharding/build.sbt +++ /dev/null @@ -1,8 +0,0 @@ -import akka.{ AkkaBuild, Dependencies, Formatting, MultiNode, ScaladocNoVerificationOfDiagrams, OSGi } - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.clusterSharding -Dependencies.clusterSharding - -enablePlugins(MultiNode, ScaladocNoVerificationOfDiagrams) diff --git a/akka-cluster-tools/build.sbt b/akka-cluster-tools/build.sbt deleted file mode 100644 index fc9cfe36c8..0000000000 --- a/akka-cluster-tools/build.sbt +++ /dev/null @@ -1,8 +0,0 @@ -import akka.{ AkkaBuild, Dependencies, Formatting, MultiNode, ScaladocNoVerificationOfDiagrams, OSGi } - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.clusterTools -Dependencies.clusterTools - -enablePlugins(MultiNode, ScaladocNoVerificationOfDiagrams) diff --git a/akka-cluster/build.sbt b/akka-cluster/build.sbt deleted file mode 100644 index cf565250ca..0000000000 --- a/akka-cluster/build.sbt +++ /dev/null @@ -1,12 +0,0 @@ -import akka.{ AkkaBuild, Dependencies, Formatting, OSGi, MultiNodeScalaTest } -import com.typesafe.sbt.SbtMultiJvm.MultiJvmKeys._ - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.cluster -Dependencies.cluster - -// disable parallel tests -parallelExecution in Test := false - -enablePlugins(MultiNodeScalaTest) diff --git a/akka-contrib/build.sbt b/akka-contrib/build.sbt deleted file mode 100644 index 502f3d7117..0000000000 --- a/akka-contrib/build.sbt +++ /dev/null @@ -1,20 +0,0 @@ -import akka.{ AkkaBuild, Dependencies, Formatting, OSGi, MultiNode, ScaladocNoVerificationOfDiagrams } - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.contrib -Dependencies.contrib - -description := """| - |This subproject provides a home to modules contributed by external - |developers which may or may not move into the officially supported code - |base over time. A module in this subproject 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. A module may be dropped in any release - |without prior deprecation. The Lightbend subscription does not cover - |support for these modules. - |""".stripMargin - -enablePlugins(MultiNode, ScaladocNoVerificationOfDiagrams) -disablePlugins(MimaPlugin) diff --git a/akka-distributed-data/build.sbt b/akka-distributed-data/build.sbt deleted file mode 100644 index 6eafa20bc2..0000000000 --- a/akka-distributed-data/build.sbt +++ /dev/null @@ -1,8 +0,0 @@ -import akka.{ AkkaBuild, Dependencies, Formatting, MultiNode, Unidoc, OSGi } - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.distributedData -Dependencies.distributedData - -enablePlugins(MultiNodeScalaTest) diff --git a/akka-docs/build.sbt b/akka-docs/build.sbt deleted file mode 100644 index c12033cab7..0000000000 --- a/akka-docs/build.sbt +++ /dev/null @@ -1,55 +0,0 @@ -import akka.{ AkkaBuild, Dependencies, Formatting, GitHub } -import akka.ValidatePullRequest._ -import com.typesafe.sbt.SbtScalariform.ScalariformKeys - -AkkaBuild.defaultSettings -AkkaBuild.dontPublishSettings -Formatting.docFormatSettings -Dependencies.docs - -unmanagedSourceDirectories in ScalariformKeys.format in Test := (unmanagedSourceDirectories in Test).value -additionalTasks in ValidatePR += paradox in Compile - -enablePlugins(ScaladocNoVerificationOfDiagrams) -disablePlugins(MimaPlugin) -enablePlugins(AkkaParadoxPlugin) - -name in (Compile, paradox) := "Akka" - -val paradoxBrowse = taskKey[Unit]("Open the docs in the default browser") -paradoxBrowse := { - import java.awt.Desktop - val rootDocFile = (target in (Compile, paradox)).value / "index.html" - val log = streams.value.log - if (!rootDocFile.exists()) log.info("No generated docs found, generate with the 'paradox' task") - else if (Desktop.isDesktopSupported) Desktop.getDesktop.open(rootDocFile) - else log.info(s"Couldn't open default browser, but docs are at $rootDocFile") -} - -paradoxProperties ++= Map( - "akka.canonical.base_url" -> "http://doc.akka.io/docs/akka/current", - "github.base_url" -> GitHub.url(version.value), // for links like this: @github[#1](#1) or @github[83986f9](83986f9) - "extref.akka.http.base_url" -> "http://doc.akka.io/docs/akka-http/current/%s", - "extref.wikipedia.base_url" -> "https://en.wikipedia.org/wiki/%s", - "extref.github.base_url" -> (GitHub.url(version.value) + "/%s"), // for links to our sources - "extref.samples.base_url" -> "https://github.com/akka/akka-samples/tree/2.5/%s", - "extref.ecs.base_url" -> "https://example.lightbend.com/v1/download/%s", - "scaladoc.akka.base_url" -> "https://doc.akka.io/api/akka/2.5", - "scaladoc.akka.http.base_url" -> "https://doc.akka.io/api/akka-http/current", - "javadoc.akka.base_url" -> "https://doc.akka.io/japi/akka/2.5", - "javadoc.akka.http.base_url" -> "http://doc.akka.io/japi/akka-http/current", - "scala.version" -> scalaVersion.value, - "scala.binary_version" -> scalaBinaryVersion.value, - "akka.version" -> version.value, - "sigar_loader.version" -> "1.6.6-rev002", - "algolia.docsearch.api_key" -> "543bad5ad786495d9ccd445ed34ed082", - "algolia.docsearch.index_name" -> "akka_io", - "google.analytics.account" -> "UA-21117439-1", - "google.analytics.domain.name" -> "akka.io", - "snip.code.base_dir" -> (sourceDirectory in Test).value.getAbsolutePath, - "snip.akka.base_dir" -> (baseDirectory in ThisBuild).value.getAbsolutePath, - "fiddle.code.base_dir" -> (sourceDirectory in Test).value.getAbsolutePath -) -paradoxGroups := Map("Languages" -> Seq("Scala", "Java")) - -resolvers += Resolver.jcenterRepo diff --git a/akka-multi-node-testkit/build.sbt b/akka-multi-node-testkit/build.sbt deleted file mode 100644 index 7a096ae4de..0000000000 --- a/akka-multi-node-testkit/build.sbt +++ /dev/null @@ -1,5 +0,0 @@ -import akka.{AkkaBuild, Formatting} - -AkkaBuild.mayChangeSettings -AkkaBuild.defaultSettings -Formatting.formatSettings diff --git a/akka-osgi/build.sbt b/akka-osgi/build.sbt deleted file mode 100644 index e3cdbded9e..0000000000 --- a/akka-osgi/build.sbt +++ /dev/null @@ -1,8 +0,0 @@ -import akka.{ AkkaBuild, Dependencies, Formatting, OSGi } - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.osgi -Dependencies.osgi - -parallelExecution in Test := false diff --git a/akka-persistence-query/build.sbt b/akka-persistence-query/build.sbt deleted file mode 100644 index b41a1b2b60..0000000000 --- a/akka-persistence-query/build.sbt +++ /dev/null @@ -1,10 +0,0 @@ -import akka.{ AkkaBuild, Dependencies, Formatting, ScaladocNoVerificationOfDiagrams, OSGi } - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.persistenceQuery -Dependencies.persistenceQuery - -fork in Test := true - -enablePlugins(ScaladocNoVerificationOfDiagrams) diff --git a/akka-persistence-shared/build.sbt b/akka-persistence-shared/build.sbt deleted file mode 100644 index 09f964143f..0000000000 --- a/akka-persistence-shared/build.sbt +++ /dev/null @@ -1,10 +0,0 @@ -import akka._ - -AkkaBuild.defaultSettings -AkkaBuild.dontPublishSettings -Formatting.formatSettings -Dependencies.persistenceShared - -fork in Test := true - -disablePlugins(MimaPlugin) diff --git a/akka-persistence-tck/build.sbt b/akka-persistence-tck/build.sbt deleted file mode 100644 index c7951b60ec..0000000000 --- a/akka-persistence-tck/build.sbt +++ /dev/null @@ -1,10 +0,0 @@ -import akka.{ AkkaBuild, Dependencies, Formatting, OSGi } - -AkkaBuild.defaultSettings -Formatting.formatSettings -// OSGi.persistenceTck TODO: we do need to export this as OSGi bundle too? -Dependencies.persistenceTck - -fork in Test := true - -disablePlugins(MimaPlugin) diff --git a/akka-persistence/build.sbt b/akka-persistence/build.sbt deleted file mode 100644 index 234ad152ab..0000000000 --- a/akka-persistence/build.sbt +++ /dev/null @@ -1,8 +0,0 @@ -import akka.{ AkkaBuild, Dependencies, Formatting, OSGi } - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.persistence -Dependencies.persistence - -fork in Test := true diff --git a/akka-protobuf/build.sbt b/akka-protobuf/build.sbt deleted file mode 100644 index 323f1bc30e..0000000000 --- a/akka-protobuf/build.sbt +++ /dev/null @@ -1,8 +0,0 @@ -import akka.{ AkkaBuild, Formatting, OSGi, Unidoc, Dependencies } - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.protobuf - -enablePlugins(ScaladocNoVerificationOfDiagrams) -disablePlugins(MimaPlugin) diff --git a/akka-remote-tests/build.sbt b/akka-remote-tests/build.sbt deleted file mode 100644 index 2c08eed141..0000000000 --- a/akka-remote-tests/build.sbt +++ /dev/null @@ -1,14 +0,0 @@ -import akka.{ AkkaBuild, Dependencies, Formatting, MultiNodeScalaTest, Unidoc } -import com.typesafe.sbt.SbtMultiJvm.MultiJvmKeys._ - -AkkaBuild.defaultSettings -AkkaBuild.dontPublishSettings -Formatting.formatSettings -Dependencies.remoteTests - -// disable parallel tests -parallelExecution in Test := false -publishArtifact in Compile := false - -enablePlugins(MultiNodeScalaTest) -disablePlugins(MimaPlugin) diff --git a/akka-remote/build.sbt b/akka-remote/build.sbt deleted file mode 100644 index 774c0d698e..0000000000 --- a/akka-remote/build.sbt +++ /dev/null @@ -1,8 +0,0 @@ -import akka.{AkkaBuild, Dependencies, Formatting, OSGi} - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.remote -Dependencies.remote - -parallelExecution in Test := false diff --git a/akka-slf4j/build.sbt b/akka-slf4j/build.sbt deleted file mode 100644 index 218cbf56e5..0000000000 --- a/akka-slf4j/build.sbt +++ /dev/null @@ -1,6 +0,0 @@ -import akka.{ AkkaBuild, Dependencies, Formatting, OSGi } - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.slf4j -Dependencies.slf4j diff --git a/akka-stream-testkit/build.sbt b/akka-stream-testkit/build.sbt deleted file mode 100644 index 089d706f75..0000000000 --- a/akka-stream-testkit/build.sbt +++ /dev/null @@ -1,6 +0,0 @@ -import akka._ - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.streamTestkit -Dependencies.streamTestkit diff --git a/akka-stream-tests-tck/build.sbt b/akka-stream-tests-tck/build.sbt deleted file mode 100644 index 5097260b2d..0000000000 --- a/akka-stream-tests-tck/build.sbt +++ /dev/null @@ -1,14 +0,0 @@ -import akka._ - -AkkaBuild.defaultSettings -AkkaBuild.dontPublishSettings -Formatting.formatSettings -Dependencies.streamTestsTck - -disablePlugins(MimaPlugin) - -// These TCK tests are using System.gc(), which -// is causing long GC pauses when running with G1 on -// the CI build servers. Therefore we fork these tests -// to run with small heap without G1. -fork in Test := true diff --git a/akka-stream-tests/build.sbt b/akka-stream-tests/build.sbt deleted file mode 100644 index f57f53bd4b..0000000000 --- a/akka-stream-tests/build.sbt +++ /dev/null @@ -1,8 +0,0 @@ -import akka._ - -AkkaBuild.defaultSettings -AkkaBuild.dontPublishSettings -Formatting.formatSettings -Dependencies.streamTests - -disablePlugins(MimaPlugin) diff --git a/akka-stream/build.sbt b/akka-stream/build.sbt deleted file mode 100644 index 1b71f0dba0..0000000000 --- a/akka-stream/build.sbt +++ /dev/null @@ -1,8 +0,0 @@ -import akka._ - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.stream -Dependencies.stream - -enablePlugins(spray.boilerplate.BoilerplatePlugin) diff --git a/akka-testkit/build.sbt b/akka-testkit/build.sbt deleted file mode 100644 index c4cf14f141..0000000000 --- a/akka-testkit/build.sbt +++ /dev/null @@ -1,8 +0,0 @@ -import akka.{ AkkaBuild, Formatting, OSGi, Dependencies } - -AkkaBuild.defaultSettings -Formatting.formatSettings -OSGi.testkit -Dependencies.testkit // to fix scaladoc generation - -initialCommands += "import akka.testkit._" diff --git a/akka-typed-testkit/build.sbt b/akka-typed-testkit/build.sbt deleted file mode 100644 index ea235f557d..0000000000 --- a/akka-typed-testkit/build.sbt +++ /dev/null @@ -1,6 +0,0 @@ -import akka.{ AkkaBuild, Formatting, OSGi } - -AkkaBuild.defaultSettings -Formatting.formatSettings - -disablePlugins(MimaPlugin) diff --git a/akka-typed-tests/build.sbt b/akka-typed-tests/build.sbt deleted file mode 100644 index a457754e83..0000000000 --- a/akka-typed-tests/build.sbt +++ /dev/null @@ -1,8 +0,0 @@ -import akka.{ AkkaBuild, Formatting } - -AkkaBuild.defaultSettings -AkkaBuild.mayChangeSettings -Formatting.formatSettings - -disablePlugins(MimaPlugin) - diff --git a/akka-typed/build.sbt b/akka-typed/build.sbt deleted file mode 100644 index 293a641ea5..0000000000 --- a/akka-typed/build.sbt +++ /dev/null @@ -1,16 +0,0 @@ -import akka.{ AkkaBuild, Formatting } - -AkkaBuild.defaultSettings -AkkaBuild.mayChangeSettings -Formatting.formatSettings - -disablePlugins(MimaPlugin) - -initialCommands := """ - import akka.typed._ - import akka.typed.scaladsl.Actor - import scala.concurrent._ - import scala.concurrent.duration._ - import akka.util.Timeout - implicit val timeout = Timeout(5.seconds) -""" diff --git a/build.sbt b/build.sbt index 8786a25226..1239d3fae7 100644 --- a/build.sbt +++ b/build.sbt @@ -1,8 +1,12 @@ -enablePlugins(akka.UnidocRoot, akka.TimeStampede, akka.UnidocWithPrValidation) +enablePlugins(UnidocRoot, TimeStampede, UnidocWithPrValidation, NoPublish) disablePlugins(MimaPlugin) + import com.typesafe.sbt.SbtMultiJvm.MultiJvmKeys.MultiJvm import com.typesafe.tools.mima.plugin.MimaPlugin +import spray.boilerplate.BoilerplatePlugin import akka.AkkaBuild._ +import akka.{AkkaBuild, Dependencies, GitHub, OSGi, Protobuf, SigarLoader, VersionGenerator} +import sbt.Keys.{initialCommands, parallelExecution} initialize := { // Load system properties from a file to make configuration from Jenkins easier @@ -42,16 +46,33 @@ lazy val root = Project( .settings(unidocRootIgnoreProjects := Seq(remoteTests, benchJmh, protobuf, akkaScalaNightly, docs)) lazy val actor = akkaModule("akka-actor") + .settings(Dependencies.actor) + .settings(OSGi.actor) + .settings( + unmanagedSourceDirectories in Compile += { + val ver = scalaVersion.value.take(4) + (scalaSource in Compile).value.getParentFile / s"scala-$ver" + } + ) + .settings(VersionGenerator.settings) + .enablePlugins(BoilerplatePlugin) lazy val actorTests = akkaModule("akka-actor-tests") .dependsOn(testkit % "compile->compile;test->test") + .settings(Dependencies.actorTests) + .enablePlugins(NoPublish) + .disablePlugins(MimaPlugin, WhiteSourcePlugin) lazy val agent = akkaModule("akka-agent") .dependsOn(actor, testkit % "test->test") + .settings(Dependencies.agent) + .settings(OSGi.agent) + .enablePlugins(ScaladocNoVerificationOfDiagrams) lazy val akkaScalaNightly = akkaModule("akka-scala-nightly") // remove dependencies that we have to build ourselves (Scala STM) .aggregate(aggregatedProjects diff List[ProjectReference](agent, docs): _*) + .disablePlugins(MimaPlugin) .disablePlugins(ValidatePullRequest, MimaPlugin) lazy val benchJmh = akkaModule("akka-bench-jmh") @@ -62,18 +83,39 @@ lazy val benchJmh = akkaModule("akka-bench-jmh") persistence, distributedData, testkit ).map(_ % "compile->compile;compile->test;provided->provided"): _* - ).disablePlugins(ValidatePullRequest) + ) + .settings(Dependencies.benchJmh) + .enablePlugins(JmhPlugin, ScaladocNoVerificationOfDiagrams, NoPublish) + .disablePlugins(MimaPlugin, WhiteSourcePlugin, ValidatePullRequest) lazy val camel = akkaModule("akka-camel") .dependsOn(actor, slf4j, testkit % "test->test") + .settings(Dependencies.camel) + .settings(OSGi.camel) lazy val cluster = akkaModule("akka-cluster") .dependsOn(remote, remoteTests % "test->test" , testkit % "test->test") + .settings(Dependencies.cluster) + .settings(OSGi.cluster) + .settings(Protobuf.settings) + .settings( + parallelExecution in Test := false + ) .configs(MultiJvm) + .enablePlugins(MultiNodeScalaTest) + lazy val clusterMetrics = akkaModule("akka-cluster-metrics") .dependsOn(cluster % "compile->compile;test->test;multi-jvm->multi-jvm", slf4j % "test->compile") + .settings(OSGi.clusterMetrics) + .settings(Dependencies.clusterMetrics) + .settings(Protobuf.settings) + .settings(SigarLoader.sigarSettings) + .settings( + parallelExecution in Test := false + ) .configs(MultiJvm) + .enablePlugins(MultiNodeScalaTest) lazy val clusterSharding = akkaModule("akka-cluster-sharding") // TODO akka-persistence dependency should be provided in pom.xml artifact. @@ -81,23 +123,52 @@ lazy val clusterSharding = akkaModule("akka-cluster-sharding") // Scope "test" is alright in the pom.xml, but would have been nicer with // provided. .dependsOn( - cluster % "compile->compile;test->test;multi-jvm->multi-jvm", - distributedData, - persistence % "compile->compile;test->provided", - clusterTools) + cluster % "compile->compile;test->test;multi-jvm->multi-jvm", + distributedData, + persistence % "compile->compile;test->provided", + clusterTools + ) + .settings(Dependencies.clusterSharding) + .settings(OSGi.clusterSharding) + .settings(Protobuf.settings) .configs(MultiJvm) + .enablePlugins(MultiNode, ScaladocNoVerificationOfDiagrams) lazy val clusterTools = akkaModule("akka-cluster-tools") .dependsOn(cluster % "compile->compile;test->test;multi-jvm->multi-jvm") + .settings(Dependencies.clusterTools) + .settings(OSGi.clusterTools) + .settings(Protobuf.settings) .configs(MultiJvm) + .enablePlugins(MultiNode, ScaladocNoVerificationOfDiagrams) lazy val contrib = akkaModule("akka-contrib") .dependsOn(remote, remoteTests % "test->test", cluster, clusterTools, persistence % "compile->compile;test->provided") + .settings(Dependencies.contrib) + .settings(OSGi.contrib) + .settings( + description := """| + |This subproject provides a home to modules contributed by external + |developers which may or may not move into the officially supported code + |base over time. A module in this subproject 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. A module may be dropped in any release + |without prior deprecation. The Lightbend subscription does not cover + |support for these modules. + |""".stripMargin + ) .configs(MultiJvm) + .enablePlugins(MultiNode, ScaladocNoVerificationOfDiagrams) + .disablePlugins(MimaPlugin) lazy val distributedData = akkaModule("akka-distributed-data") .dependsOn(cluster % "compile->compile;test->test;multi-jvm->multi-jvm") + .settings(Dependencies.distributedData) + .settings(OSGi.distributedData) + .settings(Protobuf.settings) .configs(MultiJvm) + .enablePlugins(MultiNodeScalaTest) lazy val docs = akkaModule("akka-docs") .dependsOn( @@ -111,51 +182,159 @@ lazy val docs = akkaModule("akka-docs") typedTests % "compile->compile;test->test", streamTestkit % "compile->compile;test->test" ) + .settings(Dependencies.docs) + .settings( + name in (Compile, paradox) := "Akka", + paradoxProperties ++= Map( + "akka.canonical.base_url" -> "http://doc.akka.io/docs/akka/current", + "github.base_url" -> GitHub.url(version.value), // for links like this: @github[#1](#1) or @github[83986f9](83986f9) + "extref.akka.http.base_url" -> "http://doc.akka.io/docs/akka-http/current/%s", + "extref.wikipedia.base_url" -> "https://en.wikipedia.org/wiki/%s", + "extref.github.base_url" -> (GitHub.url(version.value) + "/%s"), // for links to our sources + "extref.samples.base_url" -> "https://github.com/akka/akka-samples/tree/2.5/%s", + "extref.ecs.base_url" -> "https://example.lightbend.com/v1/download/%s", + "scaladoc.akka.base_url" -> "https://doc.akka.io/api/akka/2.5", + "scaladoc.akka.http.base_url" -> "https://doc.akka.io/api/akka-http/current", + "javadoc.akka.base_url" -> "https://doc.akka.io/japi/akka/2.5", + "javadoc.akka.http.base_url" -> "http://doc.akka.io/japi/akka-http/current", + "scala.version" -> scalaVersion.value, + "scala.binary_version" -> scalaBinaryVersion.value, + "akka.version" -> version.value, + "sigar_loader.version" -> "1.6.6-rev002", + "algolia.docsearch.api_key" -> "543bad5ad786495d9ccd445ed34ed082", + "algolia.docsearch.index_name" -> "akka_io", + "google.analytics.account" -> "UA-21117439-1", + "google.analytics.domain.name" -> "akka.io", + "snip.code.base_dir" -> (sourceDirectory in Test).value.getAbsolutePath, + "snip.akka.base_dir" -> (baseDirectory in ThisBuild).value.getAbsolutePath, + "fiddle.code.base_dir" -> (sourceDirectory in Test).value.getAbsolutePath + ), + paradoxGroups := Map("Languages" -> Seq("Scala", "Java")), + resolvers += Resolver.jcenterRepo + ) + .enablePlugins(AkkaParadoxPlugin, NoPublish, ParadoxBrowse, ScaladocNoVerificationOfDiagrams) + .disablePlugins(MimaPlugin, WhiteSourcePlugin) lazy val multiNodeTestkit = akkaModule("akka-multi-node-testkit") .dependsOn(remote, testkit) + .settings(Protobuf.settings) + .settings(AkkaBuild.mayChangeSettings) lazy val osgi = akkaModule("akka-osgi") .dependsOn(actor) + .settings(Dependencies.osgi) + .settings(OSGi.osgi) + .settings( + parallelExecution in Test := false + ) lazy val persistence = akkaModule("akka-persistence") .dependsOn(actor, testkit % "test->test", protobuf) + .settings(Dependencies.persistence) + .settings(OSGi.persistence) + .settings(Protobuf.settings) + .settings( + fork in Test := true + ) lazy val persistenceQuery = akkaModule("akka-persistence-query") .dependsOn( stream, persistence % "compile->compile;provided->provided;test->test", - streamTestkit % "test") + streamTestkit % "test" + ) + .settings(Dependencies.persistenceQuery) + .settings(OSGi.persistenceQuery) + .settings( + fork in Test := true + ) + .enablePlugins(ScaladocNoVerificationOfDiagrams) lazy val persistenceShared = akkaModule("akka-persistence-shared") .dependsOn(persistence % "test->test", testkit % "test->test", remote % "test", protobuf) + .settings(Dependencies.persistenceShared) + .settings( + fork in Test := true + ) + .enablePlugins(NoPublish) + .disablePlugins(MimaPlugin, WhiteSourcePlugin) lazy val persistenceTck = akkaModule("akka-persistence-tck") .dependsOn(persistence % "compile->compile;provided->provided;test->test", testkit % "compile->compile;test->test") + .settings(Dependencies.persistenceTck) +//.settings(OSGi.persistenceTck) TODO: we do need to export this as OSGi bundle too? + .settings( + fork in Test := true + ) + .disablePlugins(MimaPlugin) lazy val protobuf = akkaModule("akka-protobuf") + .settings(OSGi.protobuf) + .enablePlugins(ScaladocNoVerificationOfDiagrams) + .disablePlugins(MimaPlugin) lazy val remote = akkaModule("akka-remote") .dependsOn(actor, stream, actorTests % "test->test", testkit % "test->test", streamTestkit % "test", protobuf) + .settings(Dependencies.remote) + .settings(OSGi.remote) + .settings(Protobuf.settings) + .settings( + parallelExecution in Test := false + ) lazy val remoteTests = akkaModule("akka-remote-tests") .dependsOn(actorTests % "test->test", remote % "test->test", streamTestkit % "test", multiNodeTestkit) + .settings(Dependencies.remoteTests) + .settings(Protobuf.settings) + .settings( + parallelExecution in Test := false + ) .configs(MultiJvm) + .enablePlugins(MultiNodeScalaTest, NoPublish) + .disablePlugins(MimaPlugin, WhiteSourcePlugin) lazy val slf4j = akkaModule("akka-slf4j") .dependsOn(actor, testkit % "test->test") + .settings(Dependencies.slf4j) + .settings(OSGi.slf4j) lazy val stream = akkaModule("akka-stream") .dependsOn(actor) + .settings(Dependencies.stream) + .settings(OSGi.stream) + .enablePlugins(BoilerplatePlugin) lazy val streamTestkit = akkaModule("akka-stream-testkit") .dependsOn(stream, testkit % "compile->compile;test->test") + .settings(Dependencies.streamTestkit) + .settings(OSGi.streamTestkit) lazy val streamTests = akkaModule("akka-stream-tests") .dependsOn(streamTestkit % "test->test", stream) + .settings(Dependencies.streamTests) + .enablePlugins(NoPublish) + .disablePlugins(MimaPlugin, WhiteSourcePlugin) lazy val streamTestsTck = akkaModule("akka-stream-tests-tck") .dependsOn(streamTestkit % "test->test", stream) + .settings(Dependencies.streamTestsTck) + .settings( + // These TCK tests are using System.gc(), which + // is causing long GC pauses when running with G1 on + // the CI build servers. Therefore we fork these tests + // to run with small heap without G1. + fork in Test := true + ) + .enablePlugins(NoPublish) + .disablePlugins(MimaPlugin, WhiteSourcePlugin) + +lazy val testkit = akkaModule("akka-testkit") + .dependsOn(actor) + .settings(Dependencies.testkit) + .settings(OSGi.testkit) + .settings( + initialCommands += "import akka.testkit._" + ) lazy val typed = akkaModule("akka-typed") .dependsOn( @@ -164,27 +343,43 @@ lazy val typed = akkaModule("akka-typed") cluster % "provided->compile", clusterTools % "provided->compile", clusterSharding % "provided->compile", - distributedData % "provided->compile") + distributedData % "provided->compile" + ) + .settings(AkkaBuild.mayChangeSettings) + .settings( + initialCommands := """ + import akka.typed._ + import akka.typed.scaladsl.Actor + import scala.concurrent._ + import scala.concurrent.duration._ + import akka.util.Timeout + implicit val timeout = Timeout(5.seconds) + """ + ) + .disablePlugins(MimaPlugin) + +lazy val typedTestkit = akkaModule("akka-typed-testkit") + .dependsOn(typed, testkit % "compile->compile;test->test") + .disablePlugins(MimaPlugin) lazy val typedTests = akkaModule("akka-typed-tests") - .dependsOn(typed, typedTestkit % "compile->compile;test->provided;test->test") - // the provided dependencies .dependsOn( + typed, + typedTestkit % "compile->compile;test->provided;test->test", + // the provided dependencies persistence % "compile->compile;test->test", cluster % "test->test", clusterTools, clusterSharding, - distributedData) - -lazy val typedTestkit = akkaModule("akka-typed-testkit") - .dependsOn(typed, testkit % "compile->compile;test->test") - -lazy val testkit = akkaModule("akka-testkit") - .dependsOn(actor) - - + distributedData + ) + .settings(AkkaBuild.mayChangeSettings) + .disablePlugins(MimaPlugin) def akkaModule(name: String): Project = Project(id = name, base = file(name)) .settings(akka.AkkaBuild.buildSettings) + .settings(akka.AkkaBuild.defaultSettings) + .settings(akka.Formatting.formatSettings) + .enablePlugins(BootstrapGenjavadoc) diff --git a/project/AkkaBuild.scala b/project/AkkaBuild.scala index 4e3a085cc5..ec08851e49 100644 --- a/project/AkkaBuild.scala +++ b/project/AkkaBuild.scala @@ -23,24 +23,12 @@ object AkkaBuild { organization := "com.typesafe.akka", version := "2.5-SNAPSHOT") - lazy val rootSettings = parentSettings ++ Release.settings ++ + lazy val rootSettings = Release.settings ++ UnidocRoot.akkaSettings ++ Formatting.formatSettings ++ Protobuf.settings ++ Seq( parallelExecution in GlobalScope := System.getProperty("akka.parallelExecution", parallelExecutionByDefault.toString).toBoolean) - val dontPublishSettings = Seq( - publishSigned := (), - publish := (), - publishArtifact in Compile := false, - whitesourceIgnore := true) - - val dontPublishDocsSettings = Seq( - sources in doc in Compile := List()) - - lazy val parentSettings = Seq( - publishArtifact := false) ++ dontPublishSettings - lazy val mayChangeSettings = Seq( description := """|This module of Akka is marked as |'may change', which means that it is in early @@ -59,10 +47,22 @@ object AkkaBuild { case null ⇒ (Resolver.mavenLocal, Seq.empty) case path ⇒ // Maven resolver settings + def deliverPattern(outputPath: File): String = + (outputPath / "[artifact]-[revision](-[classifier]).[ext]").absolutePath + val resolver = Resolver.file("user-publish-m2-local", new File(path)) (resolver, Seq( otherResolvers := resolver :: publishTo.value.toList, - publishM2Configuration := Classpaths.publishConfig(packagedArtifacts.value, None, resolverName = resolver.name, checksums = checksums.in(publishM2).value, logging = ivyLoggingLevel.value, overwrite = true))) + 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))) } lazy val resolverSettings = { @@ -93,7 +93,6 @@ object AkkaBuild { 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), javacOptions in doc ++= Seq(), - incOptions := incOptions.value.withNameHashing(true), crossVersion := CrossVersion.binary, @@ -173,7 +172,7 @@ object AkkaBuild { original.map { group ⇒ group.runPolicy match { case Tests.SubProcess(forkOptions) ⇒ - group.copy(runPolicy = Tests.SubProcess(forkOptions.copy( + group.copy(runPolicy = Tests.SubProcess(forkOptions.withWorkingDirectory( workingDirectory = Some(new File(System.getProperty("user.dir")))))) case _ ⇒ group } diff --git a/project/Dependencies.scala b/project/Dependencies.scala index eb6a16bb50..c1986917e9 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -154,7 +154,7 @@ object Dependencies { val persistenceQuery = l ++= Seq(Test.scalatest.value, Test.junit, Test.commonsIo) - val persistenceTck = l ++= Seq(Test.scalatest.value.copy(configurations = Some("compile")), Test.junit.copy(configurations = Some("compile"))) + val persistenceTck = l ++= Seq(Test.scalatest.value.withConfigurations(Some("compile")), Test.junit.withConfigurations(Some("compile"))) val persistenceShared = l ++= Seq(Provided.levelDB, Provided.levelDBNative) diff --git a/project/Doc.scala b/project/Doc.scala index aaf2f21c53..b0111dd69d 100644 --- a/project/Doc.scala +++ b/project/Doc.scala @@ -4,8 +4,10 @@ package akka import sbt._ -import sbtunidoc.Plugin.UnidocKeys._ -import sbtunidoc.Plugin.{ ScalaUnidoc, JavaUnidoc, Genjavadoc, scalaJavaUnidocSettings, genjavadocExtraSettings, scalaUnidocSettings } +import sbtunidoc.BaseUnidocPlugin.autoImport.{ unidoc, unidocProjectFilter } +import sbtunidoc.JavaUnidocPlugin.autoImport.JavaUnidoc +import sbtunidoc.ScalaUnidocPlugin.autoImport.ScalaUnidoc +import sbtunidoc.GenJavadocPlugin.autoImport.Genjavadoc import sbt.Keys._ import sbt.File import scala.annotation.tailrec @@ -100,15 +102,14 @@ object UnidocRoot extends AutoPlugin { import autoImport._ override def trigger = noTrigger + override def requires = + UnidocRoot.CliOptions.genjavadocEnabled.ifTrue(sbtunidoc.ScalaUnidocPlugin && sbtunidoc.JavaUnidocPlugin && sbtunidoc.GenJavadocPlugin) + .getOrElse(sbtunidoc.ScalaUnidocPlugin) - val akkaSettings = UnidocRoot.CliOptions.genjavadocEnabled.ifTrue(Seq( - javacOptions in (JavaUnidoc, unidoc) ++= Seq("-Xdoclint:none"), - // genjavadoc needs to generate synthetic methods since the java code uses them - scalacOptions += "-P:genjavadoc:suppressSynthetic=false", - // FIXME: see #18056 - sources in (JavaUnidoc, unidoc) ~= (_.filterNot(_.getPath.contains("Access$minusControl$minusAllow$minusOrigin"))))).getOrElse(Nil) + val akkaSettings = UnidocRoot.CliOptions.genjavadocEnabled.ifTrue( + Seq(javacOptions in (JavaUnidoc, unidoc) := Seq("-Xdoclint:none"))).getOrElse(Nil) - val settings = { + override lazy val projectSettings = { def unidocRootProjectFilter(ignoreProjects: Seq[Project]) = ignoreProjects.foldLeft(inAnyProject) { _ -- inProjects(_) } @@ -117,23 +118,20 @@ object UnidocRoot extends AutoPlugin { unidocProjectFilter in JavaUnidoc := unidocRootProjectFilter(unidocRootIgnoreProjects.value), apiMappings in ScalaUnidoc := (apiMappings in (Compile, doc)).value)) } - - override lazy val projectSettings = - CliOptions.genjavadocEnabled.ifTrue(scalaJavaUnidocSettings).getOrElse(scalaUnidocSettings) ++ settings } /** * Unidoc settings for every multi-project. Adds genjavadoc specific settings. */ -object Unidoc extends AutoPlugin { +object BootstrapGenjavadoc extends AutoPlugin { override def trigger = allRequirements - override def requires = plugins.JvmPlugin + override def requires = UnidocRoot.CliOptions.genjavadocEnabled.ifTrue(sbtunidoc.GenJavadocPlugin) + .getOrElse(plugins.JvmPlugin) override lazy val projectSettings = UnidocRoot.CliOptions.genjavadocEnabled.ifTrue( - genjavadocExtraSettings ++ Seq( - scalacOptions in Compile += "-P:genjavadoc:fabricateParams=true", - unidocGenjavadocVersion in Global := "0.10", - // FIXME: see #18056 - sources in (Genjavadoc, doc) ~= (_.filterNot(_.getPath.contains("Access$minusControl$minusAllow$minusOrigin"))))).getOrElse(Seq.empty) + Seq( + scalacOptions in Compile ++= Seq("-P:genjavadoc:fabricateParams=true", "-P:genjavadoc:suppressSynthetic=false") + ) + ).getOrElse(Nil) } diff --git a/project/MiMa.scala b/project/MiMa.scala index a1c991587f..3ed748eb67 100644 --- a/project/MiMa.scala +++ b/project/MiMa.scala @@ -24,7 +24,7 @@ object MiMa extends AutoPlugin { val akka24NoStreamVersions = Seq("2.4.0", "2.4.1") val akka25Versions = (0 to latestMinorOf25).map(patch ⇒ s"2.5.$patch") val akka24StreamVersions = (2 to 12) map ("2.4." + _) - val akka24WithAtLeastScala212 = + val akka24WithScala212 = (13 to latestMinorOf24) .map("2.4." + _) .filterNot(_ == "2.4.15") // 2.4.15 was released from the wrong branch and never announced @@ -41,10 +41,10 @@ object MiMa extends AutoPlugin { else { if (!akka242NewArtifacts.contains(projectName)) akka24NoStreamVersions else Seq.empty - } ++ akka24StreamVersions ++ akka24WithAtLeastScala212 ++ akka25Versions + } ++ akka24StreamVersions ++ akka24WithScala212 ++ akka25Versions case "2.12" ⇒ - akka24WithAtLeastScala212 ++ akka25Versions + akka24WithScala212 ++ akka25Versions case "2.13" ⇒ // no Akka released for 2.13 yet, no jars to check BC against diff --git a/project/MultiNode.scala b/project/MultiNode.scala index aa038fcca8..93b04aa757 100644 --- a/project/MultiNode.scala +++ b/project/MultiNode.scala @@ -74,12 +74,21 @@ object MultiNode extends AutoPlugin { multiNodeResults.overall else testResults.overall + Tests.Output( overall, testResults.events ++ multiNodeResults.events, testResults.summaries ++ multiNodeResults.summaries) } } else Nil) + + implicit class TestResultOps(val self: TestResult) extends AnyVal { + def id: Int = self match { + case TestResult.Passed ⇒ 0 + case TestResult.Failed ⇒ 1 + case TestResult.Error ⇒ 2 + } + } } /** diff --git a/project/ParadoxBrowse.scala b/project/ParadoxBrowse.scala new file mode 100644 index 0000000000..8dd0b95171 --- /dev/null +++ b/project/ParadoxBrowse.scala @@ -0,0 +1,27 @@ +package akka + +import com.lightbend.paradox.sbt.ParadoxPlugin +import com.lightbend.paradox.sbt.ParadoxPlugin.autoImport._ +import sbt.Keys._ +import sbt._ + +object ParadoxBrowse extends AutoPlugin { + + object autoImport { + val paradoxBrowse = taskKey[Unit]("Open the docs in the default browser") + } + import autoImport._ + + override def trigger = allRequirements + override def requires = ParadoxPlugin + + override lazy val projectSettings = Seq( + paradoxBrowse := { + import java.awt.Desktop + val rootDocFile = (paradox in Compile).value / "index.html" + val log = streams.value.log + if (Desktop.isDesktopSupported) Desktop.getDesktop.open(rootDocFile) + else log.info(s"Couldn't open default browser, but docs are at $rootDocFile") + } + ) +} diff --git a/project/Protobuf.scala b/project/Protobuf.scala index 48933371ea..0a5cf73592 100644 --- a/project/Protobuf.scala +++ b/project/Protobuf.scala @@ -4,12 +4,14 @@ package akka -import sbt._ -import Process._ -import Keys._ -import com.typesafe.sbt.preprocess.Preprocess._ - import java.io.File +import java.io.PrintWriter + +import scala.sys.process._ + +import sbt._ +import sbt.util.CacheStoreFactory +import Keys._ object Protobuf { val paths = SettingKey[Seq[File]]("protobuf-paths", "The paths that contain *.proto files.") @@ -26,13 +28,14 @@ object Protobuf { generate := { val sourceDirs = paths.value val targetDirs = outputPaths.value + val log = streams.value.log if (sourceDirs.size != targetDirs.size) sys.error(s"Unbalanced number of paths and destination paths!\nPaths: $sourceDirs\nDestination Paths: $targetDirs") if (sourceDirs exists (_.exists)) { val cmd = protoc.value - val log = streams.value.log + checkProtocVersion(cmd, protocVersion.value, log) val base = baseDirectory.value @@ -85,4 +88,44 @@ object Protobuf { sys.error("protoc returned exit code: %d" format exitCode) } } + + /** + * Create a transformed version of all files in a directory, given a predicate and a transform function for each file. From sbt-site + */ + private def transformDirectory(sourceDir: File, targetDir: File, transformable: File ⇒ Boolean, transform: (File, File) ⇒ Unit, cache: File, log: Logger): File = { + val runTransform = FileFunction.cached(CacheStoreFactory(cache), FilesInfo.hash, FilesInfo.exists) { (in: ChangeReport[File], out: ChangeReport[File]) ⇒ + val map = Path.rebase(sourceDir, targetDir) + if (in.removed.nonEmpty || in.modified.nonEmpty) { + log.info("Preprocessing directory %s..." format sourceDir) + for (source ← in.removed; target ← map(source)) { + IO delete target + } + val updated = for (source ← in.modified; target ← map(source)) yield { + if (source.isFile) { + if (transformable(source)) transform(source, target) + else IO.copyFile(source, target) + } + target + } + log.info("Directory preprocessed: " + targetDir) + updated + } else Set.empty + } + val sources = (sourceDir.allPaths).get.toSet + runTransform(sources) + targetDir + } + + /** + * Transform a file, line by line. + */ + def transformFile(transform: String ⇒ String)(source: File, target: File): Unit = { + IO.reader(source) { reader ⇒ + IO.writer(target, "", IO.defaultCharset) { writer ⇒ + val pw = new PrintWriter(writer) + IO.foreachLine(reader) { line ⇒ pw.println(transform(line)) } + } + } + } + } diff --git a/project/Publish.scala b/project/Publish.scala index 6690154176..7832754e3c 100644 --- a/project/Publish.scala +++ b/project/Publish.scala @@ -25,12 +25,6 @@ object Publish extends AutoPlugin { defaultPublishTo := crossTarget.value / "repository") def akkaPomExtra = { - /* The scm info is automatic from the sbt-git plugin - - git://github.com/akka/akka.git - scm:git:git@github.com:akka/akka.git - - */ 2009 @@ -58,5 +52,19 @@ object Publish extends AutoPlugin { private def akkaCredentials: Seq[Credentials] = Option(System.getProperty("akka.publish.credentials", null)).map(f ⇒ Credentials(new File(f))).toSeq - +} + +/** + * For projects that are not to be published. + */ +object NoPublish extends AutoPlugin { + override def requires = plugins.JvmPlugin + + override def projectSettings = Seq( + publishArtifact := false, + publishArtifact in Compile := false, + publish := {}, + skip in publish := true, + publishLocal := {} + ) } diff --git a/project/Release.scala b/project/Release.scala index 00bf55a14f..8afe3e9425 100644 --- a/project/Release.scala +++ b/project/Release.scala @@ -7,7 +7,7 @@ import sbt._ import sbt.Keys._ import java.io.File import com.typesafe.sbt.pgp.PgpKeys.publishSigned -import sbtunidoc.Plugin.UnidocKeys._ +import sbtunidoc.BaseUnidocPlugin.autoImport.unidoc import com.lightbend.paradox.sbt.ParadoxKeys object Release extends ParadoxKeys { @@ -26,6 +26,8 @@ object Release extends ParadoxKeys { val projectRef = extracted.get(thisProjectRef) val repo = extracted.get(Publish.defaultPublishTo) val state1 = extracted.runAggregated(publishSigned in projectRef, state) + // Make sure you set "-Dakka.genjavadoc.enabled=true" otherwise no + // japi will be generated and this following match will fail: val (state2, Seq(api, japi)) = extracted.runTask(unidoc in Compile, state1) val (state3, docs) = extracted.runTask(paradox in ProjectRef(projectRef.build, "akka-docs") in Compile, state2) diff --git a/project/ValidatePullRequest.scala b/project/ValidatePullRequest.scala index d14a45a1dd..f9ce2e3df7 100644 --- a/project/ValidatePullRequest.scala +++ b/project/ValidatePullRequest.scala @@ -3,17 +3,20 @@ */ package akka +import com.lightbend.paradox.sbt.ParadoxPlugin +import com.lightbend.paradox.sbt.ParadoxPlugin.autoImport.paradox import com.typesafe.tools.mima.plugin.MimaKeys.mimaReportBinaryIssues import com.typesafe.tools.mima.plugin.MimaPlugin import net.virtualvoid.sbt.graph.backend.SbtUpdateReport import net.virtualvoid.sbt.graph.DependencyGraphKeys._ import net.virtualvoid.sbt.graph.ModuleGraph import org.kohsuke.github._ -import sbtunidoc.Plugin.UnidocKeys.unidoc +import sbtunidoc.BaseUnidocPlugin.autoImport.unidoc import sbt.Keys._ import sbt._ import scala.collection.immutable +import scala.sys.process._ import scala.util.matching.Regex object ValidatePullRequest extends AutoPlugin { @@ -80,24 +83,22 @@ object ValidatePullRequest extends AutoPlugin { val validatePullRequest = taskKey[Unit]("Validate pull request") val additionalTasks = taskKey[Seq[TaskKey[_]]]("Additional tasks for pull request validation") - def changedDirectoryIsDependency( - changedDirs: Set[String], - name: String, - graphsToTest: Seq[(Configuration, ModuleGraph)])(log: Logger): Boolean = { - graphsToTest exists { - case (ivyScope, deps) ⇒ - log.debug(s"Analysing [$ivyScope] scoped dependencies...") + def changedDirectoryIsDependency(changedDirs: Set[String], + name: String, + graphsToTest: Seq[(Configuration, ModuleGraph)])(log: Logger): Boolean = { + graphsToTest exists { case (ivyScope, deps) => + log.debug(s"Analysing [$ivyScope] scoped dependencies...") - deps.nodes.foreach { m ⇒ log.debug(" -> " + m.id) } + deps.nodes.foreach { m ⇒ log.debug(" -> " + m.id) } - // if this project depends on a modified module, we must test it - deps.nodes.exists { m ⇒ - // match just by name, we'd rather include too much than too little - val dependsOnModule = changedDirs.find(m.id.name contains _) - val depends = dependsOnModule.isDefined - if (depends) log.info(s"Project [$name] must be verified, because depends on [${dependsOnModule.get}]") - depends - } + // if this project depends on a modified module, we must test it + deps.nodes.exists { m => + // match just by name, we'd rather include too much than too little + val dependsOnModule = changedDirs.find(m.id.name contains _) + val depends = dependsOnModule.isDefined + if (depends) log.info(s"Project [$name] must be verified, because depends on [${dependsOnModule.get}]") + depends + } } } @@ -107,7 +108,6 @@ object ValidatePullRequest extends AutoPlugin { def runningLocally: Boolean = !runningOnJenkins override lazy val buildSettings = Seq( - sourceBranch in Global in ValidatePR := { sys.env.get(SourceBranchEnvVarName) orElse sys.env.get(SourcePullIdJenkinsEnvVarName).map("pullreq/" + _) getOrElse // Set by "GitHub pull request builder plugin" @@ -116,18 +116,19 @@ object ValidatePullRequest extends AutoPlugin { targetBranch in Global in ValidatePR := { (localTargetBranch, jenkinsTargetBranch) match { - case (Some(local), _) ⇒ local // local override - case (None, Some(branch)) ⇒ s"origin/$branch" // usually would be "master" or "release-2.3" etc - case (None, None) ⇒ "origin/master" // defaulting to diffing with "master" + case (Some(local), _) => local // local override + case (None, Some(branch)) => s"origin/$branch" // usually would be "master" or "release-2.3" etc + case (None, None) => "origin/master" // defaulting to diffing with "master" } }, buildAllKeyword in Global in ValidatePR := """PLS BUILD ALL""".r, githubEnforcedBuildAll in Global in ValidatePR := { - sys.env.get(PullIdEnvVarName).map(_.toInt) flatMap { prId ⇒ - val log = streams.value.log - val buildAllMagicPhrase = (buildAllKeyword in ValidatePR).value + val log = streams.value.log + val buildAllMagicPhrase = (buildAllKeyword in ValidatePR).value + + sys.env.get(PullIdEnvVarName).map(_.toInt) flatMap { prId => log.info("Checking GitHub comments for PR validation options...") try { @@ -136,12 +137,11 @@ object ValidatePullRequest extends AutoPlugin { val comments = gh.getRepository("akka/akka").getIssue(prId).getComments.asScala def triggersBuildAll(c: GHIssueComment): Boolean = buildAllMagicPhrase.findFirstIn(c.getBody).isDefined - comments collectFirst { - case c if triggersBuildAll(c) ⇒ - BuildCommentForcedAll(buildAllMagicPhrase.toString(), c) + comments collectFirst { case c if triggersBuildAll(c) => + BuildCommentForcedAll(buildAllMagicPhrase.toString(), c) } } catch { - case ex: Exception ⇒ + case ex: Exception => log.warn("Unable to reach GitHub! Exception was: " + ex.getMessage) None } @@ -160,10 +160,11 @@ object ValidatePullRequest extends AutoPlugin { val diffOutput = s"git diff $target --name-only".!!.split("\n") val diffedModuleNames = diffOutput - .map(l ⇒ l.trim) - .filter(l ⇒ + .map(l => l.trim) + .filter(l => l.startsWith("akka-") || - (l.startsWith("project") && l != "project/MiMa.scala")) + (l.startsWith("project") && l != "project/MiMa.scala") + ) .map(l ⇒ l.takeWhile(_ != '/')) .toSet @@ -174,16 +175,18 @@ object ValidatePullRequest extends AutoPlugin { val dirtyDirectories = statusOutput .map(l ⇒ l.trim.dropWhile(_ != ' ').drop(1)) .map(_.takeWhile(_ != '/')) - .filter(dir ⇒ dir.startsWith("akka-") || dir == "project") + .filter(dir => dir.startsWith("akka-") || dir == "project") .toSet log.info("Detected uncommitted changes in directories (including in dependency analysis): " + dirtyDirectories.mkString("[", ",", "]")) dirtyDirectories } + val allModuleNames = dirtyModuleNames ++ diffedModuleNames log.info("Detected changes in directories: " + allModuleNames.mkString("[", ", ", "]")) allModuleNames - }) + } + ) override lazy val projectSettings = inConfig(ValidatePR)(Defaults.testTasks) ++ Seq( testOptions in ValidatePR += Tests.Argument(TestFrameworks.ScalaTest, "-l", "performance"), @@ -204,7 +207,7 @@ object ValidatePullRequest extends AutoPlugin { val thisProjectId = CrossVersion(scalaVersion.value, scalaBinaryVersion.value)(projectID.value) def graphFor(updateReport: UpdateReport, config: Configuration): (Configuration, ModuleGraph) = - config -> SbtUpdateReport.fromConfigurationReport(updateReport.configuration(config.name).get, thisProjectId) + config -> SbtUpdateReport.fromConfigurationReport(updateReport.configuration(config).get, thisProjectId) def isDependency: Boolean = changedDirectoryIsDependency( @@ -236,34 +239,34 @@ object ValidatePullRequest extends AutoPlugin { buildMode.log(name.value, log) val validationTasks = buildMode.task.toSeq ++ (buildMode match { - case BuildSkip ⇒ Seq.empty // do not run the additional task if project is skipped during pr validation - case _ ⇒ (additionalTasks in ValidatePR).value + case BuildSkip => Seq.empty // do not run the additional task if project is skipped during pr validation + case _ => (additionalTasks in ValidatePR).value }) // Create a task for every validation task key and // then zip all of the tasks together discarding outputs. // Task failures are propagated as normal. - val zero: Def.Initialize[Seq[Task[Any]]] = Def.setting { Seq(task()) } - validationTasks.map(taskKey ⇒ Def.task { taskKey.value }).foldLeft(zero) { (acc, current) ⇒ - acc.zipWith(current) { - case (taskSeq, task) ⇒ - taskSeq :+ task.asInstanceOf[Task[Any]] + val zero: Def.Initialize[Seq[Task[Any]]] = Def.setting { Seq(task(()))} + validationTasks.map(taskKey => Def.task { taskKey.value } ).foldLeft(zero) { (acc, current) => + acc.zipWith(current) { case (taskSeq, task) => + taskSeq :+ task.asInstanceOf[Task[Any]] } - } apply { tasks: Seq[Task[Any]] ⇒ - tasks.join map { seq ⇒ () /* Ignore the sequence of unit returned */ } + } apply { tasks: Seq[Task[Any]] => + tasks.join map { seq => () /* Ignore the sequence of unit returned */ } } - }.value) + }.value + ) } /** - * This autoplugin adds Multi Jvm tests to validatePullRequest task. - * It is needed, because ValidatePullRequest autoplugin does not depend on MultiNode and - * therefore test:executeTests is not yet modified to include multi-jvm tests when ValidatePullRequest - * build strategy is being determined. - * - * Making ValidatePullRequest depend on MultiNode is impossible, as then ValidatePullRequest - * autoplugin would trigger only on projects which have both of these plugins enabled. - */ +* This autoplugin adds Multi Jvm tests to validatePullRequest task. +* It is needed, because ValidatePullRequest autoplugin does not depend on MultiNode and +* therefore test:executeTests is not yet modified to include multi-jvm tests when ValidatePullRequest +* build strategy is being determined. +* +* Making ValidatePullRequest depend on MultiNode is impossible, as then ValidatePullRequest +* autoplugin would trigger only on projects which have both of these plugins enabled. +*/ object MultiNodeWithPrValidation extends AutoPlugin { import ValidatePullRequest._ @@ -275,16 +278,31 @@ object MultiNodeWithPrValidation extends AutoPlugin { } /** - * This autoplugin adds MiMa binary issue reporting to validatePullRequest task, - * when a project has MimaPlugin autoplugin enabled. - */ +* This autoplugin adds MiMa binary issue reporting to validatePullRequest task, +* when a project has MimaPlugin autoplugin enabled. +*/ object MimaWithPrValidation extends AutoPlugin { import ValidatePullRequest._ override def trigger = allRequirements override def requires = ValidatePullRequest && MimaPlugin override lazy val projectSettings = Seq( - additionalTasks in ValidatePR += mimaReportBinaryIssues) + additionalTasks in ValidatePR += mimaReportBinaryIssues + ) +} + +/** + * This autoplugin adds Paradox doc generation to validatePullRequest task, + * when a project has ParadoxPlugin autoplugin enabled. + */ +object ParadoxWithPrValidation extends AutoPlugin { + import ValidatePullRequest._ + + override def trigger = allRequirements + override def requires = ValidatePullRequest && ParadoxPlugin + override lazy val projectSettings = Seq( + additionalTasks in ValidatePR += paradox in Compile + ) } object UnidocWithPrValidation extends AutoPlugin { @@ -292,5 +310,6 @@ object UnidocWithPrValidation extends AutoPlugin { override def trigger = noTrigger override lazy val projectSettings = Seq( - additionalTasks in ValidatePR += unidoc in Compile) + additionalTasks in ValidatePR += unidoc in Compile + ) } diff --git a/project/Version.scala b/project/VersionGenerator.scala similarity index 91% rename from project/Version.scala rename to project/VersionGenerator.scala index 3ff5bce3ed..6db8b7dfa2 100644 --- a/project/Version.scala +++ b/project/VersionGenerator.scala @@ -9,9 +9,9 @@ import sbt.Keys._ /** * Generate version.conf and akka/Version.scala files based on the version setting. */ -object Version { +object VersionGenerator { - def versionSettings: Seq[Setting[_]] = inConfig(Compile)(Seq( + val settings: Seq[Setting[_]] = inConfig(Compile)(Seq( resourceGenerators += generateVersion(resourceManaged, _ / "version.conf", """|akka.version = "%s" |"""), diff --git a/project/build.properties b/project/build.properties index c091b86ca4..b7dd3cb2ae 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.16 +sbt.version=1.0.2 diff --git a/project/plugins.sbt b/project/plugins.sbt index 73682692bf..c52f4e9aa7 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,45 +1,24 @@ -resolvers += Classpaths.typesafeResolver - // need this to resolve http://jcenter.bintray.com/org/jenkins-ci/jenkins/1.26/ // which is used by plugin "org.kohsuke" % "github-api" % "1.68" resolvers += "Bintray Jcenter" at "https://jcenter.bintray.com/" +libraryDependencies += "org.kohsuke" % "github-api" % "1.68" // these comment markers are for including code into the docs //#sbt-multi-jvm -addSbtPlugin("com.typesafe.sbt" % "sbt-multi-jvm" % "0.3.8") +addSbtPlugin("com.typesafe.sbt" % "sbt-multi-jvm" % "0.4.0") //#sbt-multi-jvm addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.1") - -addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.7.1") - -addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.1") - +addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.2") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.18") - -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") - -addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.3.3") - -addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "1.0.0") - +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0-M1") +addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.1") +addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "2.0.0") // FIXME broken on jdk9 addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.27") - -addSbtPlugin("pl.project13.sbt" % "sbt-jol" % "0.1.1") - -addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.0-RC1") - -// for advanced PR validation features -addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2") - -libraryDependencies += "org.kohsuke" % "github-api" % "1.68" - -addSbtPlugin("io.spray" % "sbt-boilerplate" % "0.6.0") - -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.10") - -addSbtPlugin("com.lightbend.akka" % "sbt-paradox-akka" % "0.3") - +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.2.2-RC2") +addSbtPlugin("io.spray" % "sbt-boilerplate" % "0.6.1") +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.3.1") +addSbtPlugin("com.lightbend.akka" % "sbt-paradox-akka" % "0.4") addSbtPlugin("com.lightbend" % "sbt-whitesource" % "0.1.6") - addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.3") +addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.0") // for advanced PR validation features