|
| 1 | + |
| 2 | +val scala211 = "2.11.12" |
| 3 | +val scala212 = "2.12.12" |
| 4 | +val scala213 = "2.13.3" |
| 5 | + |
| 6 | +val cucumberVersion = "6.8.2" |
| 7 | +val jacksonVersion = "2.11.3" |
| 8 | +val mockitoScalaVersion = "1.16.0" |
| 9 | +val junitVersion = "4.13.1" |
| 10 | + |
| 11 | +scalaVersion := scala213 |
| 12 | + |
| 13 | +// Source: https://nathankleyn.com/2019/05/13/recommended-scalac-flags-for-2-13/ |
| 14 | +lazy val scalacOptions213 = Seq( |
| 15 | + "-deprecation", // Emit warning and location for usages of deprecated APIs. |
| 16 | + "-explaintypes", // Explain type errors in more detail. |
| 17 | + "-feature", // Emit warning and location for usages of features that should be imported explicitly. |
| 18 | + "-language:existentials", // Existential types (besides wildcard types) can be written and inferred |
| 19 | + "-language:experimental.macros", // Allow macro definition (besides implementation and application) |
| 20 | + "-language:higherKinds", // Allow higher-kinded types |
| 21 | + "-language:implicitConversions", // Allow definition of implicit functions called views |
| 22 | + "-unchecked", // Enable additional warnings where generated code depends on assumptions. |
| 23 | + "-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access. |
| 24 | + "-Xfatal-warnings", // Fail the compilation if there are any warnings. |
| 25 | + "-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver. |
| 26 | + "-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error. |
| 27 | + "-Xlint:delayedinit-select", // Selecting member of DelayedInit. |
| 28 | + "-Xlint:doc-detached", // A Scaladoc comment appears to be detached from its element. |
| 29 | + "-Xlint:inaccessible", // Warn about inaccessible types in method signatures. |
| 30 | + "-Xlint:infer-any", // Warn when a type argument is inferred to be `Any`. |
| 31 | + "-Xlint:missing-interpolator", // A string literal appears to be missing an interpolator id. |
| 32 | +// "-Xlint:nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'. |
| 33 | + "-Xlint:nullary-unit", // Warn when nullary methods return Unit. |
| 34 | + "-Xlint:option-implicit", // Option.apply used implicit view. |
| 35 | + "-Xlint:package-object-classes", // Class or object defined in package object. |
| 36 | + "-Xlint:poly-implicit-overload", // Parameterized overloaded implicit methods are not visible as view bounds. |
| 37 | + "-Xlint:private-shadow", // A private field (or class parameter) shadows a superclass field. |
| 38 | + "-Xlint:stars-align", // Pattern sequence wildcard must align with sequence component. |
| 39 | + "-Xlint:type-parameter-shadow", // A local type parameter shadows a type already in scope. |
| 40 | + "-Ywarn-dead-code", // Warn when dead code is identified. |
| 41 | + "-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined. |
| 42 | + "-Ywarn-numeric-widen", // Warn when numerics are widened. |
| 43 | + "-Ywarn-unused:implicits", // Warn if an implicit parameter is unused. |
| 44 | + "-Ywarn-unused:imports", // Warn if an import selector is not referenced. |
| 45 | + "-Ywarn-unused:locals", // Warn if a local definition is unused. |
| 46 | + "-Ywarn-unused:params", // Warn if a value parameter is unused. |
| 47 | + "-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused. |
| 48 | + "-Ywarn-unused:privates", // Warn if a private member is unused. |
| 49 | + "-Ywarn-value-discard", // Warn when non-Unit expression results are unused. |
| 50 | + "-Ybackend-parallelism", "8", // Enable paralellisation — change to desired number! |
| 51 | + "-Ycache-plugin-class-loader:last-modified", // Enables caching of classloaders for compiler plugins |
| 52 | + "-Ycache-macro-class-loader:last-modified", // and macro definitions. This can lead to performance improvements. |
| 53 | +) |
| 54 | + |
| 55 | +val scalacOptions212 = Seq( |
| 56 | + "-deprecation", // Emit warning and location for usages of deprecated APIs. |
| 57 | + "-encoding", "utf-8", // Specify character encoding used by source files. |
| 58 | + "-feature", // Emit warning and location for usages of features that should be imported explicitly. |
| 59 | + "-language:implicitConversions", // Allow definition of implicit functions called views |
| 60 | +) |
| 61 | + |
| 62 | +val scalacOptions211 = Seq( |
| 63 | + "-deprecation", |
| 64 | + "-encoding", "UTF-8", // yes, this is 2 args |
| 65 | + "-feature", |
| 66 | + "-language:implicitConversions" |
| 67 | +) |
| 68 | + |
| 69 | +lazy val commonSettings = Seq( |
| 70 | + organization := "io.cucumber", |
| 71 | + libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test, |
| 72 | + scalacOptions += "-target:jvm-1.8", |
| 73 | + scalacOptions ++= { |
| 74 | + CrossVersion.partialVersion(scalaVersion.value) match { |
| 75 | + case Some((2, 11)) => scalacOptions211 |
| 76 | + case Some((2, 12)) => scalacOptions212 |
| 77 | + case Some((2, 13)) => scalacOptions213 |
| 78 | + case _ => Seq() |
| 79 | + } |
| 80 | + }, |
| 81 | +) |
| 82 | + |
| 83 | +lazy val root = (project in file(".")) |
| 84 | + .settings(commonSettings) |
| 85 | + .aggregate( |
| 86 | + cucumberScala.projectRefs ++ |
| 87 | + examples.projectRefs: _* |
| 88 | + ) |
| 89 | + |
| 90 | +lazy val cucumberScala = (projectMatrix in file("cucumber-scala")) |
| 91 | + .settings(commonSettings) |
| 92 | + .settings( |
| 93 | + name := "cucumber-scala", |
| 94 | + libraryDependencies ++= Seq( |
| 95 | + "io.cucumber" % "cucumber-core" % cucumberVersion, |
| 96 | + |
| 97 | + // Users have to provide it (for JacksonDefaultDataTableTransformer) |
| 98 | + "com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion % Provided, |
| 99 | + "com.fasterxml.jackson.module" %% "jackson-module-scala" % jacksonVersion % Provided, |
| 100 | + |
| 101 | + "junit" % "junit" % junitVersion % Test, |
| 102 | + "io.cucumber" % "cucumber-junit" % cucumberVersion % Test, |
| 103 | + "org.mockito" %% "mockito-scala" % mockitoScalaVersion % Test |
| 104 | + ), |
| 105 | + libraryDependencies ++= { |
| 106 | + CrossVersion.partialVersion(scalaVersion.value) match { |
| 107 | + case Some((2, n)) if n <= 12 => List("org.scala-lang.modules" %% "scala-collection-compat" % "2.2.0") |
| 108 | + case _ => Nil |
| 109 | + } |
| 110 | + }, |
| 111 | + unmanagedSourceDirectories in Compile ++= { |
| 112 | + val sourceDir = (sourceDirectory in Compile).value |
| 113 | + CrossVersion.partialVersion(scalaVersion.value) match { |
| 114 | + case Some((2, n)) if n <= 11 => Seq(sourceDir / "scala-2.11") |
| 115 | + case _ => Seq() |
| 116 | + } |
| 117 | + }, |
| 118 | + scalacOptions ++= Seq() |
| 119 | + ) |
| 120 | + .jvmPlatform(scalaVersions = Seq(scala213, scala212, scala211)) |
| 121 | + |
| 122 | +lazy val examples = (projectMatrix in file("examples")) |
| 123 | + .settings(commonSettings) |
| 124 | + .settings( |
| 125 | + name := "scala-examples", |
| 126 | + libraryDependencies ++= Seq( |
| 127 | + "io.cucumber" % "cucumber-junit" % cucumberVersion % Test, |
| 128 | + "junit" % "junit" % junitVersion % Test |
| 129 | + ) |
| 130 | + ) |
| 131 | + .dependsOn(cucumberScala % Test) |
| 132 | + .jvmPlatform(scalaVersions = Seq(scala213, scala212)) |
| 133 | + |
| 134 | +// TODO src jar ? |
| 135 | +// TODO javadoc jar |
| 136 | + |
| 137 | +// TODO OSS publish settings |
| 138 | +// But not the examples |
| 139 | + |
| 140 | +// TODO Makefile |
0 commit comments