Skip to content

Commit 818b8a6

Browse files
committed
Cross-compile to Scala 2.11
1 parent c86ddad commit 818b8a6

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

.ci_scripts/validate.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44

55
echo "[INFO] Check the source format"
66

7-
sbt ++$TRAVIS_SCALA_VERSION scalafmt test:scalafmt > /dev/null
7+
sbt scalafmt test:scalafmt > /dev/null
88
git diff --exit-code || (cat >> /dev/stdout <<EOF
99
[ERROR] Scalafmt check failed, see differences above.
1010
To fix, format your sources using sbt scalafmt test:scalafmt before submitting a pull request.
@@ -15,4 +15,4 @@ false
1515

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

18-
sbt ++$TRAVIS_SCALA_VERSION testOnly
18+
sbt clean +test

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ sudo: false
22
language: scala
33
jdk:
44
- oraclejdk8
5-
scala: 2.12.7
65
cache:
76
directories:
87
- $HOME/.ivy2

build.sbt

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ name := "query-monad-code"
22

33
version := "1.0-SNAPSHOT"
44

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

7-
// Common values
8-
val commonSettings = Seq(
9-
organization := "com.zengularity",
10-
crossPaths := false,
11-
scalacOptions ++= Seq(
8+
def scalacOptionsVersion(scalaVersion: String) = {
9+
val defaultOptions = Seq(
1210
"-deprecation", // Emit warning and location for usages of deprecated APIs.
1311
"-encoding",
1412
"utf-8", // Specify character encoding used by source files.
@@ -21,15 +19,32 @@ val commonSettings = Seq(
2119
"-Yno-adapted-args", // Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver.
2220
"-Ypartial-unification", // Enable partial unification in type constructor inference
2321
"-Ywarn-dead-code", // Warn when dead code is identified.
24-
"-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined.
2522
"-Ywarn-inaccessible", // Warn about inaccessible types in method signatures.
2623
"-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`.
2724
"-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'.
2825
"-Ywarn-nullary-unit", // Warn when nullary methods return Unit.
2926
"-Ywarn-numeric-widen", // Warn when numerics are widened.
3027
"-Ywarn-unused", // Warn if unused.
3128
"-Ywarn-value-discard" // Warn when non-Unit expression results are unused.
32-
),
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),
3348
scalacOptions in (Compile, console) ~= (_.filterNot(
3449
Set(
3550
"-Ywarn-unused:imports",

0 commit comments

Comments
 (0)