-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.sbt
137 lines (110 loc) · 3.77 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
organization := "$organization$"
name := "$name$"
/*
* Compatibility version. Use this to declare what version with
* which `master` remains in compatibility. This is literally
* backwards from how -SNAPSHOT versioning works, but it avoids
* the need to pre-declare (before work is done) what kind of
* compatibility properties the next version will have (i.e. major
* or minor bump).
*
* As an example, the builds of a project might go something like
* this:
*
* - 0.0-hash1
* - 0.0-hash2
* - 0.0-hash3
* - 0.1
* - 0.1-hash1
* - 0.1-hash2
* - 0.2
* - 0.2-hash1
* - 0.2-hash2
* - 0.2-hash3
* - 0.2-hash4
* - 1.0
*
* The value of BaseVersion starts at 0.0, then increments to 0.1
* when that release is tagged, and so on. Again, this is all to
* avoid pre-committing to a major/minor bump before the work is
* done (see: Scala 2.8).
*/
val BaseVersion = "0.0"
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/"))
/***********************************************************************\
Boilerplate below these lines
\***********************************************************************/
// parses Scala versions out of .travis.yml (doesn't support build matrices)
crossScalaVersions := {
import org.yaml.snakeyaml.Yaml
import scala.collection.JavaConverters._
import java.io.{FileInputStream => FIS}
import java.{util => ju}
val yaml = new Yaml
val fis = new FIS(baseDirectory.value / ".travis.yml")
try {
val list = Option(yaml.load(fis)) collect {
case map: ju.Map[_, _] => Option(map.get("scala"))
} flatten
list collect {
case versions: ju.List[_] => versions.asScala.toList map { _.toString }
} getOrElse List("$scala_version$")
} finally {
fis.close()
}
}
scalaVersion := crossScalaVersions.value.last
coursierUseSbtCredentials := true
coursierChecksums := Nil // workaround for nexus sync bugs
addCompilerPlugin("org.spire-math" % "kind-projector" % "0.9.3" cross CrossVersion.binary)
// Adapted from Rob Norris' post at https://tpolecat.github.io/2014/04/11/scalac-flags.html
scalacOptions ++= Seq(
"-language:_",
"-deprecation",
"-encoding", "UTF-8", // yes, this is 2 args
"-feature",
"-unchecked",
"-Xfatal-warnings",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-dead-code"
)
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor >= 11 => Seq(
"-Ywarn-unused-import", // Not available in 2.10
"-Ywarn-numeric-widen" // In 2.10 this produces a some strange spurious error
)
case _ => Seq.empty
}
}
scalacOptions ++= {
scalaVersion.value match {
case "2.11.9" => Seq("-Ypartial-unification")
case v if v startsWith "2.12" => Seq("-Ypartial-unification")
case _ => Seq.empty
}
}
scalacOptions in Test += "-Yrangepos"
scalacOptions in (Compile, console) ~= (_ filterNot (Set("-Xfatal-warnings", "-Ywarn-unused-import").contains))
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value
libraryDependencies ++= {
scalaVersion.value match {
case "2.11.8" => Seq(compilerPlugin("com.milessabin" % "si2712fix-plugin" % "1.2.0" cross CrossVersion.full))
case "2.10.6" => Seq(compilerPlugin("com.milessabin" % "si2712fix-plugin" % "1.2.0" cross CrossVersion.full))
case _ => Seq.empty
}
}
enablePlugins(GitVersioning)
val ReleaseTag = """^v([\\d\\.]+)\$""".r
git.baseVersion := BaseVersion
git.gitTagToVersionNumber := {
case ReleaseTag(version) => Some(version)
case _ => None
}
git.formattedShaVersion := {
val suffix = git.makeUncommittedSignifierSuffix(git.gitUncommittedChanges.value, git.uncommittedSignifier.value)
git.gitHeadCommit.value map { _.substring(0, 7) } map { sha =>
git.baseVersion.value + "-" + sha + suffix
}
}