2019-02-25 10:23:36 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2019 Lightbend Inc. <https://www.lightbend.com>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package akka
|
|
|
|
|
|
|
|
|
|
import sbt._
|
2019-04-04 15:35:18 +02:00
|
|
|
import Keys.{ scalacOptions, _ }
|
2019-02-25 10:23:36 -08:00
|
|
|
import sbt.plugins.JvmPlugin
|
|
|
|
|
|
|
|
|
|
object AkkaDisciplinePlugin extends AutoPlugin with ScalafixSupport {
|
|
|
|
|
|
2019-02-26 11:54:03 -08:00
|
|
|
import scoverage.ScoverageKeys._
|
2019-02-25 10:23:36 -08:00
|
|
|
import scalafix.sbt.ScalafixPlugin
|
|
|
|
|
|
|
|
|
|
override def trigger: PluginTrigger = allRequirements
|
|
|
|
|
override def requires: Plugins = JvmPlugin && ScalafixPlugin
|
|
|
|
|
override lazy val projectSettings = disciplineSettings
|
2019-03-26 14:41:29 +01:00
|
|
|
|
2019-04-15 11:39:38 +00:00
|
|
|
val nonFatalWarningsFor = Set(
|
|
|
|
|
// We allow warnings in docs to get the 'snippets' right
|
|
|
|
|
"akka-docs",
|
|
|
|
|
// To be removed from Akka
|
|
|
|
|
"akka-agent",
|
|
|
|
|
"akka-camel",
|
|
|
|
|
"akka-contrib",
|
|
|
|
|
// To be reviewed
|
|
|
|
|
"akka-actor-typed",
|
|
|
|
|
"akka-actor-typed-tests",
|
|
|
|
|
"akka-cluster",
|
|
|
|
|
"akka-cluster-sharding-typed",
|
|
|
|
|
"akka-bench-jmh",
|
|
|
|
|
"akka-bench-jmh-typed",
|
|
|
|
|
"akka-multi-node-testkit",
|
|
|
|
|
"akka-persistence-tck",
|
|
|
|
|
"akka-persistence-typed",
|
|
|
|
|
"akka-persistence-query",
|
|
|
|
|
"akka-remote",
|
|
|
|
|
"akka-stream-testkit",
|
|
|
|
|
"akka-stream-tests",
|
|
|
|
|
"akka-stream-tests-tck",
|
|
|
|
|
"akka-testkit"
|
|
|
|
|
)
|
2019-03-26 14:41:29 +01:00
|
|
|
|
2019-04-04 15:35:18 +02:00
|
|
|
val strictProjects = Set("akka-discovery", "akka-protobuf", "akka-coordination")
|
2019-02-25 10:23:36 -08:00
|
|
|
|
2019-04-04 15:35:18 +02:00
|
|
|
lazy val scalaFixSettings = Seq(Compile / scalacOptions += "-Yrangepos")
|
2019-02-25 10:23:36 -08:00
|
|
|
|
2019-04-04 15:35:18 +02:00
|
|
|
lazy val scoverageSettings =
|
|
|
|
|
Seq(coverageMinimum := 70, coverageFailOnMinimum := false, coverageOutputHTML := true, coverageHighlighting := {
|
2019-02-25 10:23:36 -08:00
|
|
|
import sbt.librarymanagement.{ SemanticSelector, VersionNumber }
|
|
|
|
|
!VersionNumber(scalaVersion.value).matchesSemVer(SemanticSelector("<=2.11.1"))
|
|
|
|
|
})
|
2019-03-26 14:41:29 +01:00
|
|
|
|
2019-04-16 00:10:42 -07:00
|
|
|
lazy val silencerSettings = {
|
|
|
|
|
val silencerVersion = "1.3.1"
|
|
|
|
|
Seq(
|
|
|
|
|
libraryDependencies ++= Seq(
|
|
|
|
|
compilerPlugin("com.github.ghik" %% "silencer-plugin" % silencerVersion),
|
|
|
|
|
"com.github.ghik" %% "silencer-lib" % silencerVersion % Provided))
|
|
|
|
|
}
|
2019-04-04 15:35:18 +02:00
|
|
|
|
2019-02-25 10:23:36 -08:00
|
|
|
lazy val disciplineSettings =
|
|
|
|
|
scalaFixSettings ++
|
2019-03-26 14:41:29 +01:00
|
|
|
silencerSettings ++
|
2019-03-20 08:12:40 +00:00
|
|
|
scoverageSettings ++ Seq(
|
2019-03-26 14:41:29 +01:00
|
|
|
Compile / scalacOptions ++= (
|
2019-04-15 11:39:38 +00:00
|
|
|
if (!scalaVersion.value.startsWith("2.11") && !nonFatalWarningsFor(name.value)) Seq("-Xfatal-warnings")
|
2019-04-04 15:35:18 +02:00
|
|
|
else Seq.empty
|
|
|
|
|
),
|
2019-04-04 09:58:21 +01:00
|
|
|
Test / scalacOptions --= testUndicipline,
|
2019-02-25 10:23:36 -08:00
|
|
|
Compile / console / scalacOptions --= Seq("-deprecation", "-Xfatal-warnings", "-Xlint", "-Ywarn-unused:imports"),
|
2019-04-03 13:13:44 +02:00
|
|
|
Compile / scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
|
2019-04-04 15:35:18 +02:00
|
|
|
case Some((2, 13)) =>
|
|
|
|
|
disciplineScalacOptions -- Set(
|
|
|
|
|
"-Ywarn-inaccessible",
|
|
|
|
|
"-Ywarn-infer-any",
|
|
|
|
|
"-Ywarn-nullary-override",
|
|
|
|
|
"-Ywarn-nullary-unit",
|
|
|
|
|
"-Ypartial-unification",
|
|
|
|
|
"-Yno-adapted-args")
|
|
|
|
|
case Some((2, 12)) =>
|
|
|
|
|
disciplineScalacOptions
|
|
|
|
|
case _ =>
|
|
|
|
|
Nil
|
|
|
|
|
}).toSeq,
|
2019-03-29 16:54:27 +01:00
|
|
|
Compile / doc / scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
|
2019-04-04 15:35:18 +02:00
|
|
|
case Some((2, 11)) =>
|
|
|
|
|
Seq("-no-link-warnings")
|
|
|
|
|
case _ =>
|
|
|
|
|
Seq.empty
|
|
|
|
|
}),
|
2019-04-03 13:13:44 +02:00
|
|
|
Compile / scalacOptions --=
|
|
|
|
|
(if (strictProjects.contains(name.value)) Seq.empty
|
2019-04-04 15:35:18 +02:00
|
|
|
else undisciplineScalacOptions.toSeq),
|
2019-04-03 13:13:44 +02:00
|
|
|
// Discipline is not needed for the docs compilation run (which uses
|
|
|
|
|
// different compiler phases from the regular run), and in particular
|
|
|
|
|
// '-Ywarn-unused:explicits' breaks 'sbt ++2.13.0-M5 akka-actor/doc'
|
|
|
|
|
// https://github.com/akka/akka/issues/26119
|
2019-04-04 15:35:18 +02:00
|
|
|
Compile / doc / scalacOptions --= disciplineScalacOptions.toSeq :+ "-Xfatal-warnings")
|
2019-02-25 10:23:36 -08:00
|
|
|
|
2019-04-04 09:58:21 +01:00
|
|
|
val testUndicipline = Seq(
|
2019-04-04 15:35:18 +02:00
|
|
|
"-Ywarn-dead-code", // ??? used in compile only specs
|
2019-04-04 09:58:21 +01:00
|
|
|
"-Ywarn-value-discard" // Ignoring returned assertions
|
|
|
|
|
)
|
|
|
|
|
|
2019-02-25 10:23:36 -08:00
|
|
|
/**
|
2019-04-04 15:35:18 +02:00
|
|
|
* Remain visibly filtered for future code quality work and removing.
|
|
|
|
|
*/
|
|
|
|
|
val undisciplineScalacOptions = Set("-Ywarn-value-discard", "-Ywarn-numeric-widen", "-Yno-adapted-args")
|
2019-02-25 10:23:36 -08:00
|
|
|
|
2019-03-01 13:39:08 +01:00
|
|
|
/** These options are desired, but some are excluded for the time being*/
|
2019-03-20 08:12:40 +00:00
|
|
|
val disciplineScalacOptions = Set(
|
2019-02-25 10:23:36 -08:00
|
|
|
// start: must currently remove, version regardless
|
|
|
|
|
"-Ywarn-value-discard",
|
|
|
|
|
"-Ywarn-numeric-widen",
|
2019-03-26 14:41:29 +01:00
|
|
|
"-Yno-adapted-args",
|
2019-02-25 10:23:36 -08:00
|
|
|
// end
|
2019-03-19 08:12:51 +01:00
|
|
|
"-deprecation",
|
2019-03-01 13:39:08 +01:00
|
|
|
"-Xlint",
|
2019-02-25 10:23:36 -08:00
|
|
|
"-Ywarn-dead-code",
|
|
|
|
|
"-Ywarn-inaccessible",
|
|
|
|
|
"-Ywarn-infer-any",
|
|
|
|
|
"-Ywarn-nullary-override",
|
|
|
|
|
"-Ywarn-nullary-unit",
|
|
|
|
|
"-Ywarn-unused:_",
|
|
|
|
|
"-Ypartial-unification",
|
2019-04-04 15:35:18 +02:00
|
|
|
"-Ywarn-extra-implicit")
|
2019-02-25 10:23:36 -08:00
|
|
|
|
|
|
|
|
}
|