Skip to content

Commit 7918416

Browse files
guilgalystankoua
authored andcommitted
Cross-build the project for Scala 2.11 (#19)
* Move scalafmt config file to the usual location * Update SBT and update dependencies * Cross-compile to Scala 2.11 * Format build definition files
1 parent 9fc2b2a commit 7918416

File tree

8 files changed

+44
-37
lines changed

8 files changed

+44
-37
lines changed

.ci_scripts/validate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ false
1515

1616
echo "[INFO] Running tests" >> /dev/stdout
1717

18-
sbt ++$TRAVIS_SCALA_VERSION testOnly
18+
sbt ++$TRAVIS_SCALA_VERSION test
File renamed without changes.

.travis.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
sudo: false
22
language: scala
3+
scala:
4+
- 2.12.7
5+
- 2.11.12
36
jdk:
47
- oraclejdk8
5-
scala: 2.12.4
68
cache:
79
directories:
8-
- $HOME/.ivy2
9-
- $HOME/.sbt
10-
script: ./.ci_scripts/validate.sh
10+
- $HOME/.ivy2
11+
- $HOME/.sbt
12+
script: ./.ci_scripts/validate.sh

build.sbt

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
import Dependencies._
2-
31
name := "query-monad-code"
42

53
version := "1.0-SNAPSHOT"
64

7-
scalaVersion in ThisBuild := "2.12.6"
5+
ThisBuild / scalaVersion := "2.12.7"
6+
ThisBuild / crossScalaVersions := Seq("2.11.12", "2.12.7")
87

9-
// Common values
10-
val commonSettings = Seq(
11-
organization := "com.zengularity",
12-
crossPaths := false,
13-
scalacOptions ++= Seq(
8+
def scalacOptionsVersion(scalaVersion: String) = {
9+
val defaultOptions = Seq(
1410
"-deprecation", // Emit warning and location for usages of deprecated APIs.
1511
"-encoding",
1612
"utf-8", // Specify character encoding used by source files.
@@ -23,15 +19,32 @@ val commonSettings = Seq(
2319
"-Yno-adapted-args", // Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver.
2420
"-Ypartial-unification", // Enable partial unification in type constructor inference
2521
"-Ywarn-dead-code", // Warn when dead code is identified.
26-
"-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined.
2722
"-Ywarn-inaccessible", // Warn about inaccessible types in method signatures.
2823
"-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`.
2924
"-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'.
3025
"-Ywarn-nullary-unit", // Warn when nullary methods return Unit.
3126
"-Ywarn-numeric-widen", // Warn when numerics are widened.
3227
"-Ywarn-unused", // Warn if unused.
3328
"-Ywarn-value-discard" // Warn when non-Unit expression results are unused.
34-
),
29+
)
30+
val v211Options = Seq(
31+
"-Xsource:2.12" // See https://github.com/scala/scala/releases/tag/v2.11.11
32+
)
33+
val v212Options = Seq(
34+
"-Ywarn-extra-implicit" // Warn when more than one implicit parameter section is defined.
35+
)
36+
37+
CrossVersion.partialVersion(scalaVersion) match {
38+
case Some((2L, 11L)) => defaultOptions ++ v211Options
39+
case _ => defaultOptions ++ v212Options
40+
}
41+
}
42+
43+
// Common values
44+
def commonSettings = Seq(
45+
organization := "com.zengularity",
46+
crossPaths := false,
47+
scalacOptions ++= scalacOptionsVersion(scalaVersion.value),
3548
scalacOptions in (Compile, console) ~= (_.filterNot(
3649
Set(
3750
"-Ywarn-unused:imports",
@@ -51,12 +64,9 @@ val commonSettings = Seq(
5164
)
5265

5366
// Scalafmt
54-
scalafmtOnCompile in ThisBuild := true
55-
scalafmtOnCompile := true
56-
scalafmtTestOnCompile in ThisBuild := true
57-
scalafmtTestOnCompile := true
58-
scalafmtConfig in ThisBuild := file("project/scalafmt.conf")
67+
ThisBuild / scalafmtOnCompile := true
5968

69+
// Wartremover
6070
wartremoverErrors ++= Warts.unsafe
6171

6272
//

examples/todo-app/app/controller/TodoController.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class TodoController(
9191
ConnectedAction.async { implicit request =>
9292
check(login) {
9393
val query = for {
94-
- <- SqlQueryT.fromQuery[ErrorOrResult, Todo](
94+
_ <- SqlQueryT.fromQuery[ErrorOrResult, Todo](
9595
todoStore
9696
.getTodo(todoId)
9797
.map(_.toRight("Todo doesn't exist"))

project/Dependencies.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ object Dependencies {
55

66
lazy val acolytePlay = "org.eu.acolyte" %% "play-jdbc" % "1.0.51"
77

8-
lazy val anorm = "org.playframework.anorm" %% "anorm" % "2.6.0"
8+
lazy val anorm = "org.playframework.anorm" %% "anorm" % "2.6.2"
99

10-
lazy val cats = "org.typelevel" %% "cats-core" % "1.0.1"
10+
lazy val cats = "org.typelevel" %% "cats-core" % "1.4.0"
1111

12-
lazy val h2 = "com.h2database" % "h2" % "1.4.196"
13-
14-
lazy val postgres = "org.postgresql" % "postgresql" % "42.2.2"
12+
lazy val h2 = "com.h2database" % "h2" % "1.4.197"
13+
14+
lazy val postgres = "org.postgresql" % "postgresql" % "42.2.5"
1515

1616
lazy val scalaLogging = "com.typesafe.scala-logging" %% "scala-logging" % "3.9.0"
1717

18-
lazy val specs2 = "org.specs2" %% "specs2-core" % "4.0.2"
18+
lazy val specs2 = "org.specs2" %% "specs2-core" % "4.3.5"
1919

2020
lazy val jbcrypt = "org.mindrot" % "jbcrypt" % "0.4"
2121
}

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.2.1
1+
sbt.version=1.2.6

project/plugins.sbt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
val neoScalafmtVersion = "1.14"
2-
addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % neoScalafmtVersion)
3-
// addSbtPlugin("com.lucidchart" % "sbt-scalafmt-coursier" % neoScalafmtVersion)
1+
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.1")
2+
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.3.7")
43

5-
// The Play plugin
6-
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.10")
7-
8-
// addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-RC13")
9-
10-
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.2.1")
4+
// The Play plugin, used for the play-sql module
5+
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.20")

0 commit comments

Comments
 (0)