|
| 1 | +import sbt.{Tests, _} |
| 2 | +import sbt.Keys._ |
| 3 | + |
| 4 | +object Configuration { |
| 5 | + val settings = Seq( |
| 6 | + organization := "tv.codely", |
| 7 | + scalaVersion := "2.12.4", |
| 8 | + // Custom folders path (/src/main/scala and /src/test/scala by default) |
| 9 | + Compile / mainClass := Some("tv.codely.scala_http_api.entry_point.ScalaHttpApi"), |
| 10 | + Compile / scalaSource := baseDirectory.value / "/src/main/scala", |
| 11 | + Test / scalaSource := baseDirectory.value / "/src/test/scala", |
| 12 | + Compile / resourceDirectory := baseDirectory.value / "conf", |
| 13 | + // Compiler options. More information: https://tpolecat.github.io/2017/04/25/scalac-flags.html |
| 14 | + javaOptions += "-Duser.timezone=UTC", |
| 15 | + scalacOptions ++= Seq( |
| 16 | + "-deprecation", // Emit warning and location for usages of deprecated APIs. |
| 17 | + "-encoding", |
| 18 | + "utf-8", // Specify character encoding used by source files. |
| 19 | + "-explaintypes", // Explain type errors in more detail. |
| 20 | + "-feature", // Emit warning and location for usages of features that should be imported explicitly. |
| 21 | + "-language:existentials", // Existential types (besides wildcard types) can be written and inferred |
| 22 | + "-language:experimental.macros", // Allow macro definition (besides implementation and application) |
| 23 | + "-language:higherKinds", // Allow higher-kinded types |
| 24 | + "-language:implicitConversions", // Allow definition of implicit functions called views |
| 25 | + "-unchecked", // Enable additional warnings where generated code depends on assumptions. |
| 26 | + "-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access. |
| 27 | + "-Xfatal-warnings", // Fail the compilation if there are any warnings. |
| 28 | + "-Xfuture", // Turn on future language features. |
| 29 | + "-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver. |
| 30 | + "-Xlint:by-name-right-associative", // By-name parameter of right associative operator. |
| 31 | + "-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error. |
| 32 | + "-Xlint:delayedinit-select", // Selecting member of DelayedInit. |
| 33 | + "-Xlint:doc-detached", // A Scaladoc comment appears to be detached from its element. |
| 34 | + "-Xlint:inaccessible", // Warn about inaccessible types in method signatures. |
| 35 | + "-Xlint:infer-any", // Warn when a type argument is inferred to be `Any`. |
| 36 | + "-Xlint:missing-interpolator", // A string literal appears to be missing an interpolator id. |
| 37 | + "-Xlint:nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'. |
| 38 | + "-Xlint:nullary-unit", // Warn when nullary methods return Unit. |
| 39 | + "-Xlint:option-implicit", // Option.apply used implicit view. |
| 40 | + "-Xlint:package-object-classes", // Class or object defined in package object. |
| 41 | + "-Xlint:poly-implicit-overload", // Parameterized overloaded implicit methods are not visible as view bounds. |
| 42 | + "-Xlint:private-shadow", // A private field (or class parameter) shadows a superclass field. |
| 43 | + "-Xlint:stars-align", // Pattern sequence wildcard must align with sequence component. |
| 44 | + "-Xlint:type-parameter-shadow", // A local type parameter shadows a type already in scope. |
| 45 | + "-Xlint:unsound-match", // Pattern match may not be typesafe. |
| 46 | + "-Yno-adapted-args", // Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver. |
| 47 | + "-Ypartial-unification", // Enable partial unification in type constructor inference |
| 48 | + "-Ywarn-dead-code", // Warn when dead code is identified. |
| 49 | + "-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined. |
| 50 | + "-Ywarn-inaccessible", // Warn about inaccessible types in method signatures. |
| 51 | + "-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`. |
| 52 | + "-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'. |
| 53 | + "-Ywarn-nullary-unit", // Warn when nullary methods return Unit. |
| 54 | + "-Ywarn-numeric-widen", // Warn when numerics are widened. |
| 55 | + "-Ywarn-unused:implicits", // Warn if an implicit parameter is unused. |
| 56 | + "-Ywarn-unused:imports", // Warn if an import selector is not referenced. |
| 57 | + "-Ywarn-unused:locals", // Warn if a local definition is unused. |
| 58 | + "-Ywarn-unused:params", // Warn if a value parameter is unused. |
| 59 | + "-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused. |
| 60 | + "-Ywarn-unused:privates", // Warn if a private member is unused. |
| 61 | + "-Ywarn-value-discard" // Warn when non-Unit expression results are unused. |
| 62 | + ), |
| 63 | + Compile / console / scalacOptions --= Seq("-Ywarn-unused:imports", "-Xfatal-warnings"), // Leave the console REPL usable :P |
| 64 | + Compile / run / scalacOptions -= "-Xcheckinit", // Expensive to run in prod |
| 65 | + Test / compile / scalacOptions --= Seq("-Xfatal-warnings"), // Due to deprecated ETA expansion used with ScalaMock |
| 66 | + // Test options |
| 67 | + Test / parallelExecution := false, |
| 68 | + Test / testForkedParallel := false, |
| 69 | + Test / fork := true, |
| 70 | + Test / testOptions ++= Seq( |
| 71 | + Tests.Argument(TestFrameworks.ScalaTest, "-u", "target/test-reports"), // Save test reports |
| 72 | + Tests.Argument("-oDF") // Show full stack traces and time spent in each test |
| 73 | + ) |
| 74 | + ) |
| 75 | +} |
0 commit comments