-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sbt
168 lines (151 loc) · 5.04 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// inspired by Spire build.sbt file
val scala210Version = "2.10.7"
val scala211Version = "2.11.12"
val scala212Version = "2.12.6"
val attributesVersion = "0.30"
val disciplineVersion = "0.8"
val fastParseVersion = "1.0.0"
val metalVersion = "0.16.0.0"
val scalaCheckVersion = "1.13.5"
val scalaTestVersion = "3.0.5"
val spireVersion = "0.16.0"
lazy val alasc = (project in file("."))
.settings(moduleName := "alasc")
.settings(alascSettings: _*)
.settings(noPublishSettings)
.aggregate(core, laws, tests)
.dependsOn(core, laws, tests)
lazy val core = (project in file("core"))
.settings(moduleName := "alasc-core")
.settings(alascSettings: _*)
.settings(commonJvmSettings: _*)
lazy val laws = (project in file("laws"))
.settings(moduleName := "alasc-laws")
.settings(alascSettings: _*)
.settings(testSettings:_*)
.settings(commonJvmSettings: _*)
.dependsOn(core)
lazy val tests = (project in file("tests"))
.settings(moduleName := "alasc-tests")
.settings(alascSettings: _*)
.settings(testSettings:_*)
.settings(noPublishSettings:_*)
.settings(commonJvmSettings: _*)
.dependsOn(core, laws)
lazy val alascSettings = buildSettings ++ commonSettings ++ publishSettings
lazy val buildSettings = Seq(
organization := "net.alasc",
scalaVersion := scala212Version,
crossScalaVersions := Seq(scala211Version, scala210Version)
)
lazy val commonSettings = Seq(
scalacOptions ++= commonScalacOptions.diff(Seq(
"-Xfatal-warnings",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard"
)),
resolvers ++= Seq(
"bintray/denisrosset/maven" at "https://dl.bintray.com/denisrosset/maven",
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases")
),
libraryDependencies ++= Seq(
"net.alasc" %% "attributes" % attributesVersion,
"org.typelevel" %% "spire" % spireVersion,
"org.typelevel" %% "spire-laws" % spireVersion,
"org.scala-metal" %% "metal-core" % metalVersion,
"org.scala-metal" %% "metal-library" % metalVersion,
"com.lihaoyi" %% "fastparse" % fastParseVersion
)
) ++ scalaMacroDependencies ++ warnUnusedImport
lazy val publishSettings = Seq(
homepage := Some(url("https://github.com/denisrosset/alasc")),
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
pomExtra := (
<scm>
<url>[email protected]:denisrosset/alasc.git</url>
<connection>scm:git:[email protected]:denisrosset/alasc.git</connection>
</scm>
<developers>
<developer>
<id>denisrosset</id>
<name>Denis Rosset</name>
<url>http://github.com/denisrosset/</url>
</developer>
</developers>
),
bintrayRepository := "maven",
publishArtifact in Test := false
)
lazy val noPublishSettings = Seq(
publish := (()),
publishLocal := (()),
publishArtifact := false
)
lazy val commonScalacOptions = Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
"-language:experimental.macros",
"-unchecked",
"-Xfatal-warnings",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfuture"
)
lazy val commonJvmSettings = Seq(
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oDF")
) ++ selectiveOptimize
// -optimize has no effect in scala-js other than slowing down the build
// do not optimize on Scala 2.10 because of optimizer bugs (cargo-cult setting
// from my experience with metal)
lazy val selectiveOptimize =
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 10)) => Seq()
case Some((2, 11)) => Seq("-optimize")
case Some((2, 12)) => Seq()
case _ => sys.error("Unknown Scala version")
}
}
lazy val warnUnusedImport = Seq(
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 10)) =>
Seq()
case Some((2, n)) if n >= 11 =>
Seq("-Ywarn-unused-import")
}
},
scalacOptions in (Compile, console) ~= {_.filterNot("-Ywarn-unused-import" == _)},
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value
)
lazy val scalaMacroDependencies: Seq[Setting[_]] = Seq(
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
// if scala 2.11+ is used, quasiquotes are merged into scala-reflect
case Some((2, scalaMajor)) if scalaMajor >= 11 => Seq()
// in Scala 2.10, quasiquotes are provided by macro paradise
case Some((2, 10)) =>
Seq(
compilerPlugin("org.scalamacros" % "paradise" % "2.0.1" cross CrossVersion.full),
"org.scalamacros" %% "quasiquotes" % "2.0.1" cross CrossVersion.binary
)
}
}
)
lazy val testSettings = Seq(
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % scalaTestVersion,
"org.typelevel" %% "discipline" % disciplineVersion,
"org.scalacheck" %% "scalacheck" % scalaCheckVersion
)
)