Skip to content

Commit

Permalink
Cross-build the project for Scala 2.11 (#19)
Browse files Browse the repository at this point in the history
* Move scalafmt config file to the usual location

* Update SBT and update dependencies

* Cross-compile to Scala 2.11

* Format build definition files
  • Loading branch information
guilgaly authored and stankoua committed Nov 30, 2018
1 parent 9fc2b2a commit 7918416
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .ci_scripts/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ false

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

sbt ++$TRAVIS_SCALA_VERSION testOnly
sbt ++$TRAVIS_SCALA_VERSION test
File renamed without changes.
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
sudo: false
language: scala
scala:
- 2.12.7
- 2.11.12
jdk:
- oraclejdk8
scala: 2.12.4
cache:
directories:
- $HOME/.ivy2
- $HOME/.sbt
script: ./.ci_scripts/validate.sh
- $HOME/.ivy2
- $HOME/.sbt
script: ./.ci_scripts/validate.sh
40 changes: 25 additions & 15 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import Dependencies._

name := "query-monad-code"

version := "1.0-SNAPSHOT"

scalaVersion in ThisBuild := "2.12.6"
ThisBuild / scalaVersion := "2.12.7"
ThisBuild / crossScalaVersions := Seq("2.11.12", "2.12.7")

// Common values
val commonSettings = Seq(
organization := "com.zengularity",
crossPaths := false,
scalacOptions ++= Seq(
def scalacOptionsVersion(scalaVersion: String) = {
val defaultOptions = Seq(
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-encoding",
"utf-8", // Specify character encoding used by source files.
Expand All @@ -23,15 +19,32 @@ val commonSettings = Seq(
"-Yno-adapted-args", // Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver.
"-Ypartial-unification", // Enable partial unification in type constructor inference
"-Ywarn-dead-code", // Warn when dead code is identified.
"-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined.
"-Ywarn-inaccessible", // Warn about inaccessible types in method signatures.
"-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`.
"-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'.
"-Ywarn-nullary-unit", // Warn when nullary methods return Unit.
"-Ywarn-numeric-widen", // Warn when numerics are widened.
"-Ywarn-unused", // Warn if unused.
"-Ywarn-value-discard" // Warn when non-Unit expression results are unused.
),
)
val v211Options = Seq(
"-Xsource:2.12" // See https://github.com/scala/scala/releases/tag/v2.11.11
)
val v212Options = Seq(
"-Ywarn-extra-implicit" // Warn when more than one implicit parameter section is defined.
)

CrossVersion.partialVersion(scalaVersion) match {
case Some((2L, 11L)) => defaultOptions ++ v211Options
case _ => defaultOptions ++ v212Options
}
}

// Common values
def commonSettings = Seq(
organization := "com.zengularity",
crossPaths := false,
scalacOptions ++= scalacOptionsVersion(scalaVersion.value),
scalacOptions in (Compile, console) ~= (_.filterNot(
Set(
"-Ywarn-unused:imports",
Expand All @@ -51,12 +64,9 @@ val commonSettings = Seq(
)

// Scalafmt
scalafmtOnCompile in ThisBuild := true
scalafmtOnCompile := true
scalafmtTestOnCompile in ThisBuild := true
scalafmtTestOnCompile := true
scalafmtConfig in ThisBuild := file("project/scalafmt.conf")
ThisBuild / scalafmtOnCompile := true

// Wartremover
wartremoverErrors ++= Warts.unsafe

//
Expand Down
2 changes: 1 addition & 1 deletion examples/todo-app/app/controller/TodoController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class TodoController(
ConnectedAction.async { implicit request =>
check(login) {
val query = for {
- <- SqlQueryT.fromQuery[ErrorOrResult, Todo](
_ <- SqlQueryT.fromQuery[ErrorOrResult, Todo](
todoStore
.getTodo(todoId)
.map(_.toRight("Todo doesn't exist"))
Expand Down
12 changes: 6 additions & 6 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ object Dependencies {

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

lazy val anorm = "org.playframework.anorm" %% "anorm" % "2.6.0"
lazy val anorm = "org.playframework.anorm" %% "anorm" % "2.6.2"

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

lazy val h2 = "com.h2database" % "h2" % "1.4.196"
lazy val postgres = "org.postgresql" % "postgresql" % "42.2.2"
lazy val h2 = "com.h2database" % "h2" % "1.4.197"

lazy val postgres = "org.postgresql" % "postgresql" % "42.2.5"

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

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

lazy val jbcrypt = "org.mindrot" % "jbcrypt" % "0.4"
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.1
sbt.version=1.2.6
13 changes: 4 additions & 9 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
val neoScalafmtVersion = "1.14"
addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % neoScalafmtVersion)
// addSbtPlugin("com.lucidchart" % "sbt-scalafmt-coursier" % neoScalafmtVersion)
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.1")
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.3.7")

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.10")

// addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-RC13")

addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.2.1")
// The Play plugin, used for the play-sql module
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.20")

0 comments on commit 7918416

Please sign in to comment.